本文整理汇总了Java中org.telegram.mtproto.transport.TcpContext类的典型用法代码示例。如果您正苦于以下问题:Java TcpContext类的具体用法?Java TcpContext怎么用?Java TcpContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TcpContext类属于org.telegram.mtproto.transport包,在下文中一共展示了TcpContext类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onChannelBroken
import org.telegram.mtproto.transport.TcpContext; //导入依赖的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();
}
示例2: onChannelBroken
import org.telegram.mtproto.transport.TcpContext; //导入依赖的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();
}
示例3: closeConnections
import org.telegram.mtproto.transport.TcpContext; //导入依赖的package包/类
public void closeConnections() {
synchronized (this.contexts) {
for (TcpContext context : this.contexts) {
context.suspendConnection(true);
this.scheduller.onConnectionDies(context.getContextId());
}
this.contexts.clear();
this.contexts.notifyAll();
}
}
示例4: internalSchedule
import org.telegram.mtproto.transport.TcpContext; //导入依赖的package包/类
private void internalSchedule() {
long time = System.nanoTime() / 1000000;
if (time - this.lastPingTime > PING_INTERVAL_REQUEST) {
this.lastPingTime = time;
synchronized (this.contexts) {
for (TcpContext context : this.contexts) {
this.scheduller.postMessageDelayed(
new MTPingDelayDisconnect(Entropy.getInstance().generateRandomId(), PING_INTERVAL),
false, PING_INTERVAL_REQUEST, 0, context.getContextId(), false);
}
}
}
}
示例5: run
import org.telegram.mtproto.transport.TcpContext; //导入依赖的package包/类
@Override
public void run() {
setPriority(Thread.MIN_PRIORITY);
while (!MTProto.this.isClosed) {
if (Logger.LOG_THREADS) {
Logger.d(MTProto.this.TAG, "Connection Fixer Iteration");
}
synchronized (MTProto.this.contexts) {
if (MTProto.this.contexts.size() >= MTProto.this.desiredConnectionCount) {
try {
MTProto.this.contexts.wait();
} catch (InterruptedException e) {
return;
}
}
}
ConnectionType type = MTProto.this.connectionRate.tryConnection();
TcpContext context = new TcpContext(MTProto.this, type.getHost(), type.getPort(), MTProto.this.tcpListener);
context.connect();
if (MTProto.this.isClosed) {
return;
}
MTProto.this.scheduller.postMessageDelayed(new MTPing(Entropy.getInstance().generateRandomId()), false, PING_TIMEOUT, 0, context.getContextId(), false);
synchronized (MTProto.this.contexts) {
MTProto.this.contexts.add(context);
MTProto.this.contextConnectionId.put(context.getContextId(), type.getId());
}
synchronized (MTProto.this.scheduller) {
MTProto.this.scheduller.notifyAll();
}
}
}
示例6: onError
import org.telegram.mtproto.transport.TcpContext; //导入依赖的package包/类
@Override
public void onError(int errorCode, TcpContext context) {
if (MTProto.this.isClosed) {
return;
}
Logger.e(MTProto.this.TAG, "OnError (#" + context.getContextId() + "): " + errorCode);
context.suspendConnection(true);
context.connect();
// Fully maintained at transport level: TcpContext dies
}
示例7: closeConnections
import org.telegram.mtproto.transport.TcpContext; //导入依赖的package包/类
public void closeConnections() {
synchronized (contexts) {
for (TcpContext context : contexts) {
context.close();
scheduller.onConnectionDies(context.getContextId());
}
contexts.clear();
contexts.notifyAll();
}
}
示例8: internalSchedule
import org.telegram.mtproto.transport.TcpContext; //导入依赖的package包/类
private void internalSchedule() {
long time = System.nanoTime() / 1000000;
if (time - lastPingTime > PING_INTERVAL_REQUEST) {
lastPingTime = time;
synchronized (contexts) {
for (TcpContext context : contexts) {
scheduller.postMessageDelayed(
new MTPingDelayDisconnect(Entropy.generateRandomId(), PING_INTERVAL),
false, PING_INTERVAL_REQUEST, 0, context.getContextId(), false);
}
}
}
}
示例9: onError
import org.telegram.mtproto.transport.TcpContext; //导入依赖的package包/类
@Override
public void onError(int errorCode, TcpContext context) {
if (isClosed) {
return;
}
Logger.d(TAG, "OnError (#" + context.getContextId() + "): " + errorCode);
// Fully maintained at transport level: TcpContext dies
}