コード例 #1
0
ファイル: IMChatServer.cs プロジェクト: atpx0001/XGames
        protected override bool OnHeatbeatDone(IMHttpContext ctx)
        {
            ClearInvalidChannels();
            if (ctx.code != 0)
            {
                Debug.Log("获取频道新聊天失败");
                ClearAll();
                return(false);
            }

            BonDocument chds = ctx.response.GetBonDocument("channels");

            if (chds == null)
            {
                ClearAll();
                return(false);
            }
            bool haveMsg = false;

            for (int i = channels.Count; --i >= 0;)
            {
                IMChannel ch = im.GetChannel(channels[i]);
                try {
                    if (!chds.Contains(ch.id))
                    {
                        ch.SetOffline();
                        continue;
                    }
                    if (SyncChannelMsgs(chds[ch.id].AsBonDocument, ch) > 0)
                    {
                        haveMsg = true;
                    }
                } catch (Exception e) {
                    Debug.Log(e);
                    ch.SetOffline();
                    continue;
                }
            }
            return(haveMsg);
        }
コード例 #2
0
ファイル: IMChatServer.cs プロジェクト: atpx0001/XGames
        protected override void OnSendDone(IMMsgForSend msg, IMHttpContext ctx)
        {
            IMChannel ch = im.GetChannel(msg.recId);

            if (ch == null)
            {
                return;
            }
            ClearInvalidChannels();
            if (ctx.code < 0)
            {
                Debug.Log("发送聊天致命错误");
                msg.Distributed = false;
                ClearAll();
                return;
            }
            if (ctx.code > 0)
            {
                Debug.Log("发送聊天错误");
                msg.Distributed = false;
                ch.SetOffline();
                return;
            }
            msg.Sent = true;
            try {
                BonDocument chd = ctx.response.GetBonDocument("channel");
                if (chd == null)
                {
                    msg.Distributed = false;
                    ch.SetOffline();
                    return;
                }
                SyncChannelMsgs(chd, ch);
            } catch (Exception e) {
                Debug.Log(e);
                msg.Distributed = false;
                ch.SetOffline();
            }
        }
コード例 #3
0
ファイル: IMChatServer.cs プロジェクト: atpx0001/XGames
 void ClearAll()
 {
     foreach (var m in sendingMsgs)
     {
         m.Distributed = false;
     }
     sendingMsgs.Clear();
     for (int i = channels.Count; --i >= 0;)
     {
         IMChannel ch2 = im.GetChannel(channels[i]);
         ch2.SetOffline();
     }
     channels.Clear();
 }