当前位置: 首页>>代码示例>>Java>>正文


Java MTProto类代码示例

本文整理汇总了Java中org.telegram.mtproto.MTProto的典型用法代码示例。如果您正苦于以下问题:Java MTProto类的具体用法?Java MTProto怎么用?Java MTProto使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MTProto类属于org.telegram.mtproto包,在下文中一共展示了MTProto类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onSessionCreated

import org.telegram.mtproto.MTProto; //导入依赖的package包/类
@Override
public void onSessionCreated(MTProto proto) {
    if (TelegramApi.this.isClosed) {
        return;
    }

    Logger.w(TelegramApi.this.TAG, proto + ": onSessionCreated");

    if (proto == TelegramApi.this.mainProto) {
        TelegramApi.this.registeredInApi.add(TelegramApi.this.primaryDc);
    } else {
        for (Map.Entry<Integer, MTProto> p : TelegramApi.this.dcProtos.entrySet()) {
            if (p.getValue() == proto) {
                TelegramApi.this.registeredInApi.add(p.getKey());
                break;
            }
        }
    }

    TelegramApi.this.apiCallback.onUpdatesInvalidated(TelegramApi.this);
}
 
开发者ID:rubenlagus,项目名称:TelegramApi,代码行数:22,代码来源:TelegramApi.java

示例2: onApiMessage

import org.telegram.mtproto.MTProto; //导入依赖的package包/类
@Override
public void onApiMessage(byte[] message, MTProto proto) {
    if (TelegramApi.this.isClosed) {
        return;
    }

    if (proto == TelegramApi.this.mainProto) {
        TelegramApi.this.registeredInApi.add(TelegramApi.this.primaryDc);
    } else {
        for (Map.Entry<Integer, MTProto> p : TelegramApi.this.dcProtos.entrySet()) {
            if (p.getValue() == proto) {
                TelegramApi.this.registeredInApi.add(p.getKey());
                break;
            }
        }
    }

    try {
        TLObject object = TelegramApi.this.apiContext.deserializeMessage(message);
        onMessageArrived(object);
    } catch (Throwable t) {
        Logger.e(TelegramApi.this.TAG, t);
    }
}
 
开发者ID:rubenlagus,项目名称:TelegramApi,代码行数:25,代码来源:TelegramApi.java

示例3: waitForAuthDc

import org.telegram.mtproto.MTProto; //导入依赖的package包/类
private MTProto waitForAuthDc(final int dcId) throws IOException, java.util.concurrent.TimeoutException {
    Logger.d(TelegramApi.this.TAG, "#" + dcId + ": waitForAuthDc");
    if (TelegramApi.this.isClosed) {
        Logger.w(TelegramApi.this.TAG, "#" + dcId + ": Api is closed");
        throw new TimeoutException();
    }

    MTProto proto = waitForDc(dcId);

    if (!TelegramApi.this.state.isAuthenticated(dcId)) {
        Logger.w(TelegramApi.this.TAG, "#" + dcId + ": exporting auth");
        TLRequestAuthExportAuthorization exportAuthorization = new TLRequestAuthExportAuthorization();
        exportAuthorization.setDcId(dcId);
        TLExportedAuthorization exAuth = doRpcCall(exportAuthorization);

        Logger.w(TelegramApi.this.TAG, "#" + dcId + ": importing auth");
        TLRequestAuthImportAuthorization tlRequestAuthImportAuthorization = new TLRequestAuthImportAuthorization();
        tlRequestAuthImportAuthorization.setId(exAuth.getId());
        tlRequestAuthImportAuthorization.setBytes(exAuth.getBytes());
        doRpcCallNonAuth(tlRequestAuthImportAuthorization, DEFAULT_TIMEOUT, dcId);

        TelegramApi.this.state.setAuthenticated(dcId, true);
    }

    return proto;
}
 
开发者ID:rubenlagus,项目名称:TelegramApi,代码行数:27,代码来源:TelegramApi.java

示例4: TcpContext

import org.telegram.mtproto.MTProto; //导入依赖的package包/类
public TcpContext(MTProto proto, String ip, int port, boolean checksum, TcpContextCallback callback) throws IOException {
    try {
        this.contextId = contextLastId.incrementAndGet();
        this.TAG = "MTProto#" + proto.getInstanceIndex() + "#Transport" + contextId;
        this.ip = ip;
        this.port = port;
        this.useChecksum = checksum;
        this.socket = new Socket();
        this.socket.connect(new InetSocketAddress(ip, port), CONNECTION_TIMEOUT);
        this.socket.setKeepAlive(true);
        this.socket.setTcpNoDelay(true);
        if (!useChecksum) {
            socket.getOutputStream().write(0xef);
        }
        this.isClosed = false;
        this.isBroken = false;
        this.callback = callback;
        this.readerThread = new ReaderThread();
        this.writerThread = new WriterThread();
        this.dieThread = new DieThread();
        this.readerThread.start();
        this.writerThread.start();
        this.dieThread.start();
    } catch (IOException e) {
        throw e;
    } catch (Throwable t) {
        throw new IOException();
    }
}
 
开发者ID:ardock,项目名称:telegram-mt,代码行数:30,代码来源:TcpContext.java

示例5: resetNetworkBackoff

import org.telegram.mtproto.MTProto; //导入依赖的package包/类
/**
 * Reset network backoff.
 */
public void resetNetworkBackoff() {
    if (this.mainProto != null) {
        this.mainProto.resetNetworkBackoff();
    }
    for (MTProto mtProto : this.dcProtos.values()) {
        mtProto.resetNetworkBackoff();
    }
}
 
开发者ID:rubenlagus,项目名称:TelegramApi,代码行数:12,代码来源:TelegramApi.java

示例6: resetConnectionInfo

import org.telegram.mtproto.MTProto; //导入依赖的package包/类
/**
 * Reset connection info.
 */
public void resetConnectionInfo() {
    this.mainProto.reloadConnectionInformation();
    synchronized (this.dcProtos) {
        for (MTProto proto : this.dcProtos.values()) {
            proto.reloadConnectionInformation();
        }
    }
}
 
开发者ID:rubenlagus,项目名称:TelegramApi,代码行数:12,代码来源:TelegramApi.java

示例7: TcpContext

import org.telegram.mtproto.MTProto; //导入依赖的package包/类
public TcpContext(MTProto proto, String ip, int port, TcpContextCallback callback) {
    this.contextId = contextLastId.incrementAndGet();
    this.connectionState = ConnectionState.TcpConnectionStageIdle;
    this.TAG = "MTProto#" + proto.getInstanceIndex() + "#Transport" + this.contextId;
    this.ip = ip;
    this.port = port;
    this.callback = callback;
    this.selector = new PyroSelector();
    this.selector.spawnNetworkThread("Selector Thread");
    BuffersStorage.getInstance();
}
 
开发者ID:rubenlagus,项目名称:TelegramApi,代码行数:12,代码来源:TcpContext.java

示例8: onRpcResult

import org.telegram.mtproto.MTProto; //导入依赖的package包/类
@Override
public void onRpcResult(int callId, byte[] response, MTProto proto) {
    if (TelegramApi.this.isClosed) {
        return;
    }

    if (proto == TelegramApi.this.mainProto) {
        TelegramApi.this.registeredInApi.add(TelegramApi.this.primaryDc);
    } else {
        for (Map.Entry<Integer, MTProto> p : TelegramApi.this.dcProtos.entrySet()) {
            if (p.getValue() == proto) {
                TelegramApi.this.registeredInApi.add(p.getKey());
                break;
            }
        }
    }

    try {
        RpcCallbackWrapper currentCallback = null;
        synchronized (TelegramApi.this.callbacks) {
            if (TelegramApi.this.sentRequests.containsKey(callId)) {
                currentCallback = TelegramApi.this.callbacks.remove(TelegramApi.this.sentRequests.remove(callId));
            }
        }
        if (currentCallback != null && currentCallback.method != null) {
            long start = System.currentTimeMillis();
            TLObject object = currentCallback.method.deserializeResponse(response, TelegramApi.this.apiContext);
            Logger.d(TelegramApi.this.TAG, "<< #" + +currentCallback.id + " deserialized " + object + " in " + (System.currentTimeMillis() - start) + " ms");

            synchronized (currentCallback) {
                if (currentCallback.isCompleted) {
                    Logger.d(TelegramApi.this.TAG, "<< #" + +currentCallback.id + " ignored " + object + " in " + currentCallback.elapsed() + " ms");
                    return;
                } else {
                    currentCallback.isCompleted = true;
                }
            }
            Logger.d(TelegramApi.this.TAG, "<< #" + +currentCallback.id + " " + object + " in " + currentCallback.elapsed() + " ms");

            synchronized (TelegramApi.this.timeoutTimes) {
                TelegramApi.this.timeoutTimes.remove(currentCallback.timeoutTime);
            }
            if (currentCallback.callback != null) {
                currentCallback.callback.onResult(object);
            }
        }
    } catch (Throwable t) {
        Logger.e(TelegramApi.this.TAG, t);
    }
}
 
开发者ID:rubenlagus,项目名称:TelegramApi,代码行数:51,代码来源:TelegramApi.java

示例9: Scheduller

import org.telegram.mtproto.MTProto; //导入依赖的package包/类
public Scheduller(MTProto mtProto, CallWrapper wrapper) {
    this.TAG = "MTProto#" + mtProto.getInstanceIndex() + "#Scheduller";
    this.wrapper = wrapper;
}
 
开发者ID:rubenlagus,项目名称:TelegramApi,代码行数:5,代码来源:Scheduller.java

示例10: Scheduller

import org.telegram.mtproto.MTProto; //导入依赖的package包/类
public Scheduller(MTProto mtProto, CallWrapper wrapper) {
    TAG = "MTProto#" + mtProto.getInstanceIndex() + "#Scheduller";
    this.wrapper = wrapper;
}
 
开发者ID:ardock,项目名称:telegram-mt,代码行数:5,代码来源:Scheduller.java


注:本文中的org.telegram.mtproto.MTProto类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。