第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定

線程中沒有實(shí)例化ConnectionManager對象

線程中沒有實(shí)例化ConnectionManager對象吧?通過構(gòu)造者模式返回的config沒有被使用

正在回答

2 回答

對應(yīng)著我的寫,就可以了。

0 回復(fù) 有任何疑惑可以回復(fù)我~


private ConnectionConfig mConfig;
private WeakReference<Context> mContext;
private NioSocketConnector mConnection;
private IoSession mSession;
private InetSocketAddress mAddress;

public ?ConnectionManager(ConnectionConfig config){
? ?this.mConfig = config;
? ?this.mContext = new WeakReference<>(config.getContext());
? ?init();
}

private void init() {
? ?mAddress = new InetSocketAddress(mConfig.getIp(),mConfig.getPort());
? ?mConnection = new NioSocketConnector();
? ?mConnection.getSessionConfig().setReadBufferSize(mConfig.getReadBufferSize());
? ?mConnection.getFilterChain().addLast("logger",new LoggingFilter());
? ?mConnection.getFilterChain().addLast("codec",new ProtocolCodecFilter(new ObjectSerializationCodecFactory()));
? ?mConnection.setHandler(new DefaultHandler(mContext.get()));
? ?mConnection.setDefaultRemoteAddress(mAddress);
}



/**
* 外層調(diào)用取得與服務(wù)器的連接
* @return
*/
public boolean connect(){
? ?Log.e("tag", "準(zhǔn)備連接");
? ?try{
? ? ? ?ConnectFuture future = mConnection.connect();
? ? ? ?future.awaitUninterruptibly();
? ? ? ?mSession = future.getSession();
? ? ? ?SessionManager.getInstance().setSeesion(mSession);

? ?}catch (Exception e){
? ? ? ?e.printStackTrace();
? ? ? ?Log.e("tag", "連接失敗");
? ? ? ?return false;
? ?}

? ?return mSession == null ? false : true;
}

/**
* 斷開連接的方法
*/
public void disConnection(){

? ?mConnection.dispose();//Dispose后,對象都不存在了
? ?mConnection = null;
? ?mSession ? ?= null;
? ?mAddress ? ?= null;
? ?mContext ? ?= null;

}

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

線程中沒有實(shí)例化ConnectionManager對象

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號