本文整理汇总了Java中org.telegram.mtproto.log.Logger类的典型用法代码示例。如果您正苦于以下问题:Java Logger类的具体用法?Java Logger怎么用?Java Logger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Logger类属于org.telegram.mtproto.log包,在下文中一共展示了Logger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deserializeBody
import org.telegram.mtproto.log.Logger; //导入依赖的package包/类
@Override
public void deserializeBody(InputStream stream, TLContext context) throws IOException {
if (this.destClass == null) {
throw new IOException("DestClass not set");
}
int count = readInt(stream);
for (int i = 0; i < count; i++) {
Logger.d("TLVECTOR", "reading: " + i + " from " + count + " (" + this.items.size() + ")" + " --> " + this.destClass);
if (this.destClass == Integer.class) {
this.items.add((T) (Integer) readInt(stream));
} else if (this.destClass == Long.class) {
this.items.add((T) (Long) readLong(stream));
} else if (this.destClass == String.class) {
this.items.add((T) readTLString(stream));
} else {
this.items.add((T) context.deserializeMessage(stream));
}
Logger.d("TLVECTOR", "Extracted " + this.items.get(i).toString());
}
}
示例2: run
import org.telegram.mtproto.log.Logger; //导入依赖的package包/类
@Override
public void run() {
setPriority(Thread.MIN_PRIORITY);
while (!MTProto.this.isClosed) {
if (Logger.LOG_THREADS) {
Logger.d(MTProto.this.TAG, "Response Iteration");
}
synchronized (MTProto.this.inQueue) {
if (MTProto.this.inQueue.isEmpty()) {
try {
MTProto.this.inQueue.wait();
} catch (InterruptedException e) {
return;
}
}
if (MTProto.this.inQueue.isEmpty()) {
continue;
}
}
MTMessage message = MTProto.this.inQueue.poll();
onMTMessage(message);
BytesCache.getInstance().put(message.getContent());
}
}
示例3: onChannelBroken
import org.telegram.mtproto.log.Logger; //导入依赖的package包/类
@Override
public void onChannelBroken(TcpContext context) {
if (MTProto.this.isClosed) {
return;
}
int contextId = context.getContextId();
Logger.d(MTProto.this.TAG, "onChannelBroken (#" + contextId + ")");
synchronized (MTProto.this.contexts) {
MTProto.this.contexts.remove(context);
if (!MTProto.this.connectedContexts.contains(contextId)) {
if (MTProto.this.contextConnectionId.containsKey(contextId)) {
MTProto.this.exponentalBackoff.onFailureNoWait();
MTProto.this.connectionRate.onConnectionFailure(MTProto.this.contextConnectionId.get(contextId));
}
}
MTProto.this.contexts.notifyAll();
}
MTProto.this.scheduller.onConnectionDies(context.getContextId());
requestSchedule();
}
示例4: suspendConnectionInternal
import org.telegram.mtproto.log.Logger; //导入依赖的package包/类
private void suspendConnectionInternal() {
synchronized (timerSync) {
if (reconnectTimer != null) {
reconnectTimer.cancel();
reconnectTimer = null;
}
}
if ((connectionState == ConnectionState.TcpConnectionStageIdle) || (connectionState == ConnectionState.TcpConnectionStageSuspended)) {
return;
}
Logger.d(TcpContext.this.TAG, "suspend connnection " + TcpContext.this);
connectionState = ConnectionState.TcpConnectionStageSuspended;
if (client != null) {
client.removeListener(TcpContext.this);
client.dropConnection();
client = null;
}
callback.onChannelBroken(TcpContext.this);
isFirstPackage = true;
if (restOfTheData != null) {
BuffersStorage.getInstance().reuseFreeBuffer(restOfTheData);
restOfTheData = null;
}
lastPacketLength = 0;
channelToken = 0;
}
示例5: readString
import org.telegram.mtproto.log.Logger; //导入依赖的package包/类
public String readString(boolean exception) {
try {
int sl = 1;
int l = getIntFromByte(this.buffer.get());
if(l >= 254) {
l = getIntFromByte(this.buffer.get()) | (getIntFromByte(this.buffer.get()) << 8) | (getIntFromByte(this.buffer.get()) << 16);
sl = 4;
}
final byte[] b = new byte[l];
this.buffer.get(b);
int i = sl;
while(((l + i) % 4) != 0) {
this.buffer.get();
i++;
}
return new String(b, "UTF-8");
} catch (Exception e) {
if (exception) {
throw new RuntimeException("read string error", e);
} else {
Logger.w("tmessages", "read string error");
}
}
return null;
}
示例6: readByteArray
import org.telegram.mtproto.log.Logger; //导入依赖的package包/类
public byte[] readByteArray(boolean exception) {
try {
int sl = 1;
int l = getIntFromByte(this.buffer.get());
if (l >= 254) {
l = getIntFromByte(this.buffer.get()) | (getIntFromByte(this.buffer.get()) << 8) | (getIntFromByte(this.buffer.get()) << 16);
sl = 4;
}
final byte[] b = new byte[l];
this.buffer.get(b);
int i = sl;
while(((l + i) % 4) != 0) {
this.buffer.get();
i++;
}
return b;
} catch (Exception e) {
if (exception) {
throw new RuntimeException("read byte array error", e);
} else {
Logger.w("tmessages", "read byte array error");
}
}
return null;
}
示例7: run
import org.telegram.mtproto.log.Logger; //导入依赖的package包/类
@Override
public void run() {
setPriority(Thread.MIN_PRIORITY);
while (!isClosed) {
if (Logger.LOG_THREADS) {
Logger.d(TAG, "Response Iteration");
}
synchronized (inQueue) {
if (inQueue.isEmpty()) {
try {
inQueue.wait();
} catch (InterruptedException e) {
return;
}
}
if (inQueue.isEmpty()) {
continue;
}
}
MTMessage message = inQueue.poll();
onMTMessage(message);
BytesCache.getInstance().put(message.getContent());
}
}
示例8: onChannelBroken
import org.telegram.mtproto.log.Logger; //导入依赖的package包/类
@Override
public void onChannelBroken(TcpContext context) {
if (isClosed) {
return;
}
int contextId = context.getContextId();
Logger.d(TAG, "onChannelBroken (#" + contextId + ")");
synchronized (contexts) {
contexts.remove(context);
if (!connectedContexts.contains(contextId)) {
if (contextConnectionId.containsKey(contextId)) {
exponentalBackoff.onFailureNoWait();
connectionRate.onConnectionFailure(contextConnectionId.get(contextId));
}
}
contexts.notifyAll();
}
scheduller.onConnectionDies(context.getContextId());
requestSchedule();
}
示例9: readBytes
import org.telegram.mtproto.log.Logger; //导入依赖的package包/类
private byte[] readBytes(int count, int timeout, InputStream stream) throws IOException {
byte[] res = BytesCache.getInstance().allocate(count);
int offset = 0;
long start = System.nanoTime();
while (offset < count) {
int readed = stream.read(res, offset, count - offset);
Thread.yield();
if (readed > 0) {
offset += readed;
onRead();
} else if (readed < 0) {
throw new IOException();
} else {
if (System.nanoTime() - start > timeout * 1000000L) {
throw new IOException();
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
Logger.e(TAG, e);
throw new IOException();
}
}
}
return res;
}
示例10: registerClass
import org.telegram.mtproto.log.Logger; //导入依赖的package包/类
public <T extends TLObject> void registerClass(Class<T> tClass) {
try {
int classId = tClass.getField("CLASS_ID").getInt(null);
this.registeredClasses.put(classId, tClass);
} catch (IllegalAccessException | NoSuchFieldException e) {
e.printStackTrace();
Logger.e(TAG, e);
}
}
示例11: registerCompatClass
import org.telegram.mtproto.log.Logger; //导入依赖的package包/类
public <T extends TLObject> void registerCompatClass(Class<T> tClass) {
try {
int classId = tClass.getField("CLASS_ID").getInt(null);
this.registeredCompatClasses.put(classId, tClass);
} catch (IllegalAccessException | NoSuchFieldException e) {
e.printStackTrace();
Logger.e(TAG, e);
}
}
示例12: skipBytes
import org.telegram.mtproto.log.Logger; //导入依赖的package包/类
/**
* Reading bytes from stream
*
* @param count bytes count
* @param stream source stream
* @return readed bytes
* @throws IOException reading exception
*/
//public static void skipBytes(int count, InputStream stream) throws IOException {
// stream.skip(count);
//}
public static void skipBytes(int count, InputStream stream) throws IOException {
byte[] bytes = new byte[count];
stream.read(bytes);
Logger.d("SKIPED", "Skypped " + count + " bytes: " + bytes);
//stream.skip(count);
}
示例13: resendAsNewMessageDelayed
import org.telegram.mtproto.log.Logger; //导入依赖的package包/类
public void resendAsNewMessageDelayed(long msgId, long delay) {
for (SchedullerPackage schedullerPackage : this.messages.values().toArray(new SchedullerPackage[0])) {
if (schedullerPackage.relatedMessageIds.contains(msgId)) {
schedullerPackage.idGenerationTime = 0;
schedullerPackage.dependMessageId = 0;
schedullerPackage.messageId = 0;
schedullerPackage.seqNo = 0;
schedullerPackage.state = STATE_QUEUED;
schedullerPackage.scheduleTime = getCurrentTime() + delay;
Logger.d(this.TAG, "Resending as new #" + schedullerPackage.id);
}
}
}
示例14: onConnectionDies
import org.telegram.mtproto.log.Logger; //导入依赖的package包/类
public synchronized void onConnectionDies(int connectionId) {
Logger.d(this.TAG, "Connection dies " + connectionId);
for (SchedullerPackage schedullerPackage : this.messages.values().toArray(new SchedullerPackage[0])) {
if (schedullerPackage.writtenToChannel != connectionId) {
continue;
}
if (schedullerPackage.queuedToChannel != -1) {
Logger.d(this.TAG, "Removing: #" + schedullerPackage.id + " " + schedullerPackage.supportTag);
forgetMessage(schedullerPackage.id);
} else {
if (schedullerPackage.isRpc) {
if (schedullerPackage.state == STATE_CONFIRMED || schedullerPackage.state == STATE_QUEUED) {
Logger.d(this.TAG, "Re-schedule: #" + schedullerPackage.id + " " + schedullerPackage.supportTag);
schedullerPackage.state = STATE_QUEUED;
schedullerPackage.lastAttemptTime = 0;
}
} else {
if (schedullerPackage.state == STATE_SENT) {
Logger.d(this.TAG, "Re-schedule: #" + schedullerPackage.id + " " + schedullerPackage.supportTag);
schedullerPackage.state = STATE_QUEUED;
schedullerPackage.lastAttemptTime = 0;
}
}
}
}
}
示例15: sendMessage
import org.telegram.mtproto.log.Logger; //导入依赖的package包/类
public int sendMessage(TLObject request, long timeout, boolean isRpc, boolean highPriority) {
final int id = this.scheduller.postMessage(request, isRpc, timeout, highPriority);
Logger.d(this.TAG, "sendMessage #" + id + " " + request.toString());
synchronized (this.scheduller) {
this.scheduller.notifyAll();
}
return id;
}