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

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

XmmppManager.?RegisterTask 方法問題

XmmppManager.RegisterTask ?方法


PacketListener packetListener = new PacketListener() {


? ? ? ? ? ? ? ? ? ? public void processPacket(Packet packet) {

? ? ? ? ? ? ? ? ? ? //添加鎖

? ? ? ? ? ? ? ? ? ? synchronized (xmppManager) {

? ? ? ? ? ? ? ? ? ? ? ? ? ? if (packet instanceof IQ) {

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? IQ response = (IQ) packet;

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? if (response.getType() == IQ.Type.ERROR) {

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? if (!response.getError().toString().contains(

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "409")) {

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Log.e(LOGTAG,

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "Unknown error while registering XMPP account! "

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? + response.getError()

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? .getCondition());

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? } else if (response.getType() == IQ.Type.RESULT) {

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? xmppManager.setUsername(newUsername);

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? xmppManager.setPassword(newPassword);

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Log.d(LOGTAG, "username=" + newUsername);

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Log.d(LOGTAG, "password=" + newPassword);


? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Editor editor = sharedPrefs.edit();

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? editor.putString(Constants.XMPP_USERNAME,

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? newUsername);

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? editor.putString(Constants.XMPP_PASSWORD,

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? newPassword);

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? editor.commit();

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? isRegisterSucceed=true;

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Log

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? .i(LOGTAG,

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "Account registered successfully");

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? xmppManager.runTask();

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? ? ? ? ? ? ? }

? ? ? ? }

? ? ? ? ? ? ? ? ? ? ? ??

? ? ? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? };


? ? ? ? ? ? ? ? connection.addPacketListener(packetListener, packetFilter);


? ? ? ? ? ? ? ? registration.setType(IQ.Type.SET);

? ? ? ? ? ? ? ? // registration.setTo(xmppHost);

? ? ? ? ? ? ? ? // Map<String, String> attributes = new HashMap<String, String>();

? ? ? ? ? ? ? ? // attributes.put("username", rUsername);

? ? ? ? ? ? ? ? // attributes.put("password", rPassword);

? ? ? ? ? ? ? ? // registration.setAttributes(attributes);

? ? ? ? ? ? ? ? registration.addAttribute("username", newUsername);

? ? ? ? ? ? ? ? registration.addAttribute("password", newPassword);

? ? ? ? ? ? ? ? connection.sendPacket(registration);

? ? ? ? ? ? ? ??

? ? ? ? ? ? ? ? //睡眠線程

? ? ? ? ? ? ? ? try {

???????????????? Thread.sleep(10*1000);

???????????????? } catch (InterruptedException e) {

???????????????? e.printStackTrace();

???????????????? }

? ? ? ? ? ? ? ? //該方法也可能出現(xiàn)問題,在10s之后,比如10.1s 客戶端獲得了服務器的數(shù)據(jù),開始了監(jiān)聽,那么?xmppManager.runTask();就會重復被執(zhí)行????

? ? ? ? ? ? ? ? synchronized(xmppManager){

????????? ? ? ? ? ? ? ? if (!isRegisterSucceed) {

????????? ? ? ? ? ? ? ? ? ? xmppManager.dropTask(1);

????????? ? ? ? ? ? ? ? ? ? ? ? ?xmppManager.runTask();

????????? ? ? ? ? ? ? ? ? ? ? ? ?xmppManager.startReconnectionThread();

????????? ? ???????????? }

? ? ? ? ? ? ?}

還有一種問題,在10s之后,下面同步代碼塊已經(jīng)走完了,比如10.1s ,客戶端獲得了服務器的數(shù)據(jù),開始了監(jiān)聽,那么?xmppManager.runTask();就會重復被執(zhí)行?????


正在回答

3 回答

重復執(zhí)行runtask 有問題??也不存在所謂重復的問題,有同步鎖,runtask取出的task肯定是不一樣的,是按照add到tasklist里面的順序取出執(zhí)行的,多runtask一次能有什么問題?畢竟都是要執(zhí)行的,有同步鎖和越界處理 ,能有什么問題

0 回復 有任何疑惑可以回復我~
#1

菜鳥精髓 提問者

效率和性能的問題
2015-11-18 回復 有任何疑惑可以回復我~

我覺得這也是個bug,但是這種情況幾乎不存在,沒必要修復這個bug

0 回復 有任何疑惑可以回復我~

我也覺得存在這個問題

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
見證Android消息推送時刻
  • 參與學習       48182    人
  • 解答問題       210    個

本課程將一步步教你如何搭建出一個自己的Android推送平臺

進入課程

XmmppManager.?RegisterTask 方法問題

我要回答 關注問題
微信客服

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

幫助反饋 APP下載

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

公眾號

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