コード例 #1
0
        public void OnSendChatRsp(uint iMessageType, object kParam)
        {
            NetworkMessageParam param = kParam as NetworkMessageParam;
            SendChatRsp         rsp   = param.rsp as SendChatRsp;

            Log4U.LogDebug(rsp.resultCode);
            if (rsp.resultCode == SendChatRsp.ResultCode.SUCCESS)
            {
                if (_waitSendChatDict.ContainsKey(param.msgID))
                {
                    SendChatReq req = param.req as SendChatReq;
                    _waitSendChatDict[param.msgID].isSend = true;
                    _waitSendChatDict.Remove(param.msgID);
                }
                MessageDispatcher.GetInstance().DispatchMessage((uint)EUIMessage.UPDATE_SEND_CHAT);
            }
            else
            {
                if (_waitSendChatDict.ContainsKey(param.msgID))
                {
                    SendChatReq req = param.req as SendChatReq;
                    _waitSendChatDict[param.msgID].isSend = false;
                    _waitSendChatDict.Remove(param.msgID);
                }
                MessageDispatcher.GetInstance().DispatchMessage((uint)EUIMessage.UPDATE_SEND_CHAT);
            }
        }
コード例 #2
0
        private IEnumerator BeginSendPacket <T>(ENetworkMessage networkMessage, T packet, uint timeoutMessage, byte[] msgIDBytes) where T : global::ProtoBuf.IExtensible
        {
            string msgID = BitConverter.ToString(msgIDBytes);

            lock (_msgIDDict)
            {
                _msgIDDict.Add(BitConverter.ToString(msgIDBytes), packet);
            }

            Log4U.LogInfo("Send : " + networkMessage + " msgID : " + msgID);

            DoBeginSendPacket <T>(networkMessage, packet, msgIDBytes);
            yield return(new WaitForSeconds(REQ_TIME_OUT));

            lock (_msgIDDict)
            {
                if (_msgIDDict.ContainsKey(msgID))
                {
                    RemoveMsgID(msgID);

                    NetworkMessageParam param = new NetworkMessageParam
                    {
                        msgID = msgID,
                        req   = packet,
                    };
                    MessageDispatcher.GetInstance().DispatchMessage(timeoutMessage, param);
                    DialogManager.GetInstance().CreateSingleButtonDialog("Send Packet Type : " + networkMessage + " msgID : " + msgID + " timeout ");
                }
            }
        }
コード例 #3
0
 public override void OnHide()
 {
     base.OnHide();
     MessageDispatcher.GetInstance().UnRegisterMessageHandler((uint)ENetworkMessage.REGISTER_RSP, OnRegisterRsp);
     MessageDispatcher.GetInstance().UnRegisterMessageHandler((uint)ENetworkMessage.LOGIN_RSP, OnLoginRsp);
     MessageDispatcher.GetInstance().UnRegisterMessageHandler((uint)EModelMessage.REQ_TIMEOUT, OnReqTimeOut);
 }
コード例 #4
0
        public override void OnHide()
        {
            base.OnHide();
            _mainMenuNaviBar.GetCurPanel().Hide();

            MessageDispatcher.GetInstance().UnRegisterMessageHandler((uint)EUIMessage.UPDATE_CHAT_LIST, OnUpdateChatList);

        }
コード例 #5
0
        public override void OnShow(object param = null)
        {
            base.OnShow(param);
            MessageDispatcher.GetInstance().RegisterMessageHandler((uint)ENetworkMessage.LOGIN_RSP, OnLoginRsp);
            MessageDispatcher.GetInstance().RegisterMessageHandler((uint)EModelMessage.REQ_TIMEOUT, OnReqTimeOut);

            _inputId.text = PlayerPrefs.GetString(GlobalVars.PREF_USER_ID);
        }
コード例 #6
0
        public override void OnShow(object param = null)
        {
            base.OnShow(param);

            _inputUserID.text = "";
            _buttonSearchFriend.interactable = false;
            MessageDispatcher.GetInstance().RegisterMessageHandler((uint)ENetworkMessage.GET_USERINFO_RSP, OnGetUserInfoRsp);
        }
コード例 #7
0
 public void OnChangeIP(string[] args)
 {
     if (args.Length >= 2)
     {
         GlobalVars.IPAddress = args[1];
         MessageDispatcher.GetInstance().DispatchMessageAsync((uint)EModelMessage.SOCKET_DISCONNECTED);
     }
 }
コード例 #8
0
        public override void OnHide()
        {
            base.OnHide();

            MessageDispatcher.GetInstance().UnRegisterMessageHandler((uint)EUIMessage.UPDATE_RECEIVE_CHAT, OnUpdateReceiveChat);
            MessageDispatcher.GetInstance().UnRegisterMessageHandler((uint)EUIMessage.UPDATE_SEND_CHAT, OnUpdateSendChat);
            MessageDispatcher.GetInstance().UnRegisterMessageHandler((uint)EUIMessage.DELETE_CHAT_ITEM, OnDeleteChatItem);
        }
コード例 #9
0
 public void OnClickToggleMemeber(bool check)
 {
     MessageDispatcher.GetInstance().DispatchMessage((uint)EUIMessage.TOGGLE_GROUP_MEMBER,
                                                     new ToggleGroupMemberParam {
         userID = _userItem.userId,
         check  = check,
     });
 }
コード例 #10
0
        public override void OnShow(object param = null)
        {
            base.OnShow(param);
            _mainMenuNaviBar.GetCurPanel().Show();

            _imageUnReadChat.gameObject.SetActive(GlobalChat.GetInstance().IsAnyUnReadChat());
            MessageDispatcher.GetInstance().RegisterMessageHandler((uint)EUIMessage.UPDATE_CHAT_LIST, OnUpdateChatList);
            
        }
コード例 #11
0
        private void FinishConnection(IAsyncResult ar)
        {
            _socket.EndConnect(ar);

            if (_socket.Connected)
            {
                MessageDispatcher.GetInstance().DispatchMessageAsync((uint)EModelMessage.SOCKET_CONNECTED, null);
            }
        }
コード例 #12
0
        public override void Release()
        {
            MessageDispatcher.GetInstance().UnRegisterMessageHandler((uint)EModelMessage.SOCKET_CONNECTED, OnSocketConnected);
            MessageDispatcher.GetInstance().UnRegisterMessageHandler((uint)EModelMessage.SOCKET_DISCONNECTED, OnSocketDisConnected);
            MessageDispatcher.GetInstance().UnRegisterMessageHandler((uint)ENetworkMessage.KEEP_ALIVE_SYNC, OnKeepAliveSync);
            MessageDispatcher.GetInstance().UnRegisterMessageHandler((uint)EModelMessage.REQ_FINISH, OnReqFinish);

            CloseConnection();
        }
コード例 #13
0
 public void OnConfirmDeleteChatBubble()
 {
     MessageDispatcher.GetInstance().DispatchMessage((uint)EUIMessage.DELETE_CHAT_ITEM,
                                                     new DeleteChatParam {
         chatBubbleFrame = this,
         chatDataItem    = _chatDataItem,
     });
     Destroy(gameObject);
 }
コード例 #14
0
        public override void Show(object param = null)
        {
            base.Show(param);


            MessageDispatcher.GetInstance().RegisterMessageHandler((uint)EUIMessage.UPDATE_PERSONAL_DETAIL, OnUpdatePersonalDetail);

            _laeblName.text = GlobalUser.GetInstance().UserName;
            _labelId.text   = GlobalUser.GetInstance().UserId;
            UIManager.GetInstance().SetImage(_imageHead, EAtlasName.Head, "00" + GlobalUser.GetInstance().HeadIndex);
        }
コード例 #15
0
        public override void Release()
        {
            MessageDispatcher.GetInstance().UnRegisterMessageHandler((uint)ENetworkMessage.GET_PERSONALINFO_RSP, OnGetPersonalInfoRsp);
            MessageDispatcher.GetInstance().UnRegisterMessageHandler((uint)ENetworkMessage.LOGIN_RSP, OnLoginRsp);
            MessageDispatcher.GetInstance().UnRegisterMessageHandler((uint)ENetworkMessage.PERSONALSETTINGS_RSP, OnPersonalSetRsp);
            MessageDispatcher.GetInstance().UnRegisterMessageHandler((uint)ENetworkMessage.PERSONALSETTINGS_RSP, OnLogOutRsp);
            MessageDispatcher.GetInstance().UnRegisterMessageHandler((uint)EModelMessage.SOCKET_CONNECTED, TryLoginWithPref);
            MessageDispatcher.GetInstance().UnRegisterMessageHandler((uint)ENetworkMessage.OFFLINE_SYNC, OnOffLineSync);

            SaveUserInfo();
        }
コード例 #16
0
        public void OnReceiveChatSync(uint iMessageType, object kParam)
        {
            ReceiveChatSync rsp = kParam as ReceiveChatSync;

            foreach (var chatItem in rsp.chatData)
            {
                AddChatDataItem(MiniConverter.ChatItemToDataItem(chatItem));
            }
            MessageDispatcher.GetInstance().DispatchMessage((uint)EUIMessage.UPDATE_CHAT_LIST, null);
            MessageDispatcher.GetInstance().DispatchMessage((uint)EUIMessage.UPDATE_RECEIVE_CHAT, null);
        }
コード例 #17
0
        public void OnSendChatTimeOut(uint iMessageType, object kParam)
        {
            NetworkMessageParam param = kParam as NetworkMessageParam;

            if (_waitSendChatDict.ContainsKey(param.msgID))
            {
                SendChatReq req = param.req as SendChatReq;
                _waitSendChatDict[param.msgID].isSend = false;
                _waitSendChatDict.Remove(param.msgID);
            }
            MessageDispatcher.GetInstance().DispatchMessage((uint)EUIMessage.UPDATE_SEND_CHAT);
        }
コード例 #18
0
        public override void Init()
        {
            base.Init();
            _friendDict = new Dictionary <string, UserItem>();

            MessageDispatcher.GetInstance().RegisterMessageHandler((uint)ENetworkMessage.GET_PERSONALINFO_RSP, OnGetPersonalInfoRsp);
            MessageDispatcher.GetInstance().RegisterMessageHandler((uint)ENetworkMessage.CHANGE_FRIEND_SYNC, OnChangeFriendSync);
            MessageDispatcher.GetInstance().RegisterMessageHandler((uint)ENetworkMessage.LOGOUT_RSP, OnLogOut);
            MessageDispatcher.GetInstance().RegisterMessageHandler((uint)ENetworkMessage.OFFLINE_SYNC, OnLogOut);
            MessageDispatcher.GetInstance().RegisterMessageHandler((uint)EModelMessage.TRY_LOGIN, OnTryLogin);

            LoadFriendDict();
        }
コード例 #19
0
        public override void Release()
        {
            base.Release();

            MessageDispatcher.GetInstance().UnRegisterMessageHandler((uint)ENetworkMessage.GET_PERSONALINFO_RSP, OnGetPersonalInfoRsp);
            MessageDispatcher.GetInstance().UnRegisterMessageHandler((uint)ENetworkMessage.CHANGE_FRIEND_SYNC, OnChangeFriendSync);
            MessageDispatcher.GetInstance().UnRegisterMessageHandler((uint)ENetworkMessage.LOGOUT_RSP, OnLogOut);
            MessageDispatcher.GetInstance().UnRegisterMessageHandler((uint)ENetworkMessage.OFFLINE_SYNC, OnLogOut);
            MessageDispatcher.GetInstance().UnRegisterMessageHandler((uint)EModelMessage.TRY_LOGIN, OnTryLogin);


            SaveFriendDict();
        }
コード例 #20
0
        public void TryLogin(string id, string password)
        {
            LoginReq req = new LoginReq
            {
                userId       = id,
                userPassword = password
            };

            _userId       = id;
            _userPassword = password;
            MessageDispatcher.GetInstance().DispatchMessage((uint)EModelMessage.TRY_LOGIN, null);
            NetworkManager.GetInstance().SendPacket <LoginReq>(ENetworkMessage.LOGIN_REQ, req);
        }
コード例 #21
0
        public void OnGetPersonalInfoRsp(uint iMessageType, object kParam)
        {
            NetworkMessageParam param = kParam as NetworkMessageParam;
            GetPersonalInfoRsp  rsp   = param.rsp as GetPersonalInfoRsp;
            GetPersonalInfoReq  req   = param.req as GetPersonalInfoReq;

            if (rsp.resultCode == GetPersonalInfoRsp.ResultCode.SUCCESS &&
                req.userInfo)
            {
                _userName  = rsp.userInfo.userName;
                _headIndex = rsp.userInfo.headIndex;
                MessageDispatcher.GetInstance().DispatchMessage((uint)EUIMessage.UPDATE_PERSONAL_DETAIL, null);
            }
        }
コード例 #22
0
        public override void Release()
        {
            base.Release();
            MessageDispatcher.GetInstance().UnRegisterMessageHandler((uint)ENetworkMessage.RECEIVE_CHAT_SYNC, OnReceiveChatSync);
            MessageDispatcher.GetInstance().UnRegisterMessageHandler((uint)ENetworkMessage.SEND_CHAT_RSP, OnSendChatRsp);
            MessageDispatcher.GetInstance().UnRegisterMessageHandler((uint)EModelMessage.SEND_CHAT_TIMEOUT, OnSendChatTimeOut);
            MessageDispatcher.GetInstance().UnRegisterMessageHandler((uint)ENetworkMessage.LOGIN_RSP, OnLoginRsp);
            MessageDispatcher.GetInstance().UnRegisterMessageHandler((uint)ENetworkMessage.LOGOUT_RSP, OnLogOutRsp);
            MessageDispatcher.GetInstance().UnRegisterMessageHandler((uint)ENetworkMessage.OFFLINE_SYNC, OnLogOutRsp);
            MessageDispatcher.GetInstance().UnRegisterMessageHandler((uint)EModelMessage.TRY_LOGIN, OnTryLogin);
            MessageDispatcher.GetInstance().UnRegisterMessageHandler((uint)ENetworkMessage.CHANGE_FRIEND_SYNC, OnChangeFriendSync);

            SaveLogDict();
        }
コード例 #23
0
        public override void Release()
        {
            base.Release();

            MessageDispatcher.GetInstance().UnRegisterMessageHandler((uint)ENetworkMessage.GET_PERSONALINFO_RSP, OnGetPersonalInfoRsp);
            MessageDispatcher.GetInstance().UnRegisterMessageHandler((uint)ENetworkMessage.CHANGE_GROUP_SYNC, OnChangeGroupSync);
            MessageDispatcher.GetInstance().UnRegisterMessageHandler((uint)ENetworkMessage.CHANGE_GROUP_RSP, OnChangeGroupRsp);
            MessageDispatcher.GetInstance().UnRegisterMessageHandler((uint)ENetworkMessage.GET_USERINFO_RSP, OnGetUserInfo);

            MessageDispatcher.GetInstance().UnRegisterMessageHandler((uint)EModelMessage.TRY_LOGIN, OnTryLogin);
            MessageDispatcher.GetInstance().UnRegisterMessageHandler((uint)ENetworkMessage.LOGOUT_RSP, OnLogOutRsp);
            MessageDispatcher.GetInstance().UnRegisterMessageHandler((uint)ENetworkMessage.OFFLINE_SYNC, OnLogOutRsp);

            SaveGroupDict();
        }
コード例 #24
0
        public override void OnShow(object param = null)
        {
            base.OnShow(param);

            if (param != null)
            {
                _chatLog = param as ChatLog;
            }

            RefreshChatLog();

            MessageDispatcher.GetInstance().RegisterMessageHandler((uint)EUIMessage.UPDATE_RECEIVE_CHAT, OnUpdateReceiveChat);
            MessageDispatcher.GetInstance().RegisterMessageHandler((uint)EUIMessage.UPDATE_SEND_CHAT, OnUpdateSendChat);
            MessageDispatcher.GetInstance().RegisterMessageHandler((uint)EUIMessage.DELETE_CHAT_ITEM, OnDeleteChatItem);
        }
コード例 #25
0
        public override void Init()
        {
            Log4U.LogInfo("Client Running...");

            _msgIDDict = new Dictionary <string, IExtensible>();
            InitForcePushMessageType();
            InitNeedReqMessageType();

            MessageDispatcher.GetInstance().RegisterMessageHandler((uint)EModelMessage.SOCKET_CONNECTED, OnSocketConnected);
            MessageDispatcher.GetInstance().RegisterMessageHandler((uint)EModelMessage.SOCKET_DISCONNECTED, OnSocketDisConnected);
            MessageDispatcher.GetInstance().RegisterMessageHandler((uint)ENetworkMessage.KEEP_ALIVE_SYNC, OnKeepAliveSync);
            MessageDispatcher.GetInstance().RegisterMessageHandler((uint)EModelMessage.REQ_FINISH, OnReqFinish);

            MessageDispatcher.GetInstance().DispatchMessageAsync((uint)EModelMessage.SOCKET_DISCONNECTED, null);
        }
コード例 #26
0
        public void OnChangeFriendSync(uint iMessageType, object kParam)
        {
            ChangeFriendSync rsp = kParam as ChangeFriendSync;

            if (rsp.changeType == ChangeFriendSync.ChangeType.ADD)
            {
                _friendDict.Add(rsp.userItem.userId, rsp.userItem);
            }
            else if (rsp.changeType == ChangeFriendSync.ChangeType.DELETE)
            {
                _friendDict.Remove(rsp.userItem.userId);
            }

            MessageDispatcher.GetInstance().DispatchMessage((uint)EUIMessage.UPDATE_FRIEND_DETAIL);
        }
コード例 #27
0
        public override void Init()
        {
            base.Init();

            MessageDispatcher.GetInstance().RegisterMessageHandler((uint)ENetworkMessage.GET_PERSONALINFO_RSP, OnGetPersonalInfoRsp);
            MessageDispatcher.GetInstance().RegisterMessageHandler((uint)ENetworkMessage.CHANGE_GROUP_SYNC, OnChangeGroupSync);
            MessageDispatcher.GetInstance().RegisterMessageHandler((uint)ENetworkMessage.CHANGE_GROUP_RSP, OnChangeGroupRsp);
            MessageDispatcher.GetInstance().RegisterMessageHandler((uint)ENetworkMessage.GET_USERINFO_RSP, OnGetUserInfo);

            MessageDispatcher.GetInstance().RegisterMessageHandler((uint)EModelMessage.TRY_LOGIN, OnTryLogin);
            MessageDispatcher.GetInstance().RegisterMessageHandler((uint)ENetworkMessage.LOGOUT_RSP, OnLogOutRsp);
            MessageDispatcher.GetInstance().RegisterMessageHandler((uint)ENetworkMessage.OFFLINE_SYNC, OnLogOutRsp);

            StartCoroutine(QueryMemberData());
        }
コード例 #28
0
        public override void Init()
        {
            MessageDispatcher.GetInstance().RegisterMessageHandler((uint)ENetworkMessage.GET_PERSONALINFO_RSP, OnGetPersonalInfoRsp);
            MessageDispatcher.GetInstance().RegisterMessageHandler((uint)ENetworkMessage.LOGIN_RSP, OnLoginRsp);
            MessageDispatcher.GetInstance().RegisterMessageHandler((uint)ENetworkMessage.PERSONALSETTINGS_RSP, OnPersonalSetRsp);
            MessageDispatcher.GetInstance().RegisterMessageHandler((uint)ENetworkMessage.LOGOUT_RSP, OnLogOutRsp);
            MessageDispatcher.GetInstance().RegisterMessageHandler((uint)EModelMessage.SOCKET_CONNECTED, TryLoginWithPref);
            MessageDispatcher.GetInstance().RegisterMessageHandler((uint)ENetworkMessage.OFFLINE_SYNC, OnOffLineSync);


            if (PlayerPrefs.HasKey(GlobalVars.PREF_USER_ID))
            {
                _userId = PlayerPrefs.GetString(GlobalVars.PREF_USER_ID);
            }
            LoadUserInfo();
        }
コード例 #29
0
        public override void Init()
        {
            base.Init();
            MessageDispatcher.GetInstance().RegisterMessageHandler((uint)ENetworkMessage.RECEIVE_CHAT_SYNC, OnReceiveChatSync);
            MessageDispatcher.GetInstance().RegisterMessageHandler((uint)ENetworkMessage.SEND_CHAT_RSP, OnSendChatRsp);
            MessageDispatcher.GetInstance().RegisterMessageHandler((uint)EModelMessage.SEND_CHAT_TIMEOUT, OnSendChatTimeOut);
            MessageDispatcher.GetInstance().RegisterMessageHandler((uint)ENetworkMessage.LOGIN_RSP, OnLoginRsp);
            MessageDispatcher.GetInstance().RegisterMessageHandler((uint)ENetworkMessage.LOGOUT_RSP, OnLogOutRsp);
            MessageDispatcher.GetInstance().RegisterMessageHandler((uint)ENetworkMessage.OFFLINE_SYNC, OnLogOutRsp);
            MessageDispatcher.GetInstance().RegisterMessageHandler((uint)EModelMessage.TRY_LOGIN, OnTryLogin);
            MessageDispatcher.GetInstance().RegisterMessageHandler((uint)ENetworkMessage.CHANGE_FRIEND_SYNC, OnChangeFriendSync);

            _chatLogDict      = new Dictionary <string, ChatLog>();
            _waitSendChatDict = new Dictionary <string, ChatDataItem>();

            LoadLogDict();
        }
コード例 #30
0
        public void OnGetPersonalInfoRsp(uint iMessageType, object kParam)
        {
            NetworkMessageParam param = kParam as NetworkMessageParam;
            GetPersonalInfoRsp  rsp   = param.rsp as GetPersonalInfoRsp;
            GetPersonalInfoReq  req   = param.req as GetPersonalInfoReq;

            if (rsp.resultCode == GetPersonalInfoRsp.ResultCode.SUCCESS &&
                req.friendInfo)
            {
                _friendDict.Clear();
                foreach (UserItem friend in rsp.friends)
                {
                    _friendDict[friend.userId] = friend;
                }
                MessageDispatcher.GetInstance().DispatchMessageAsync((uint)EUIMessage.UPDATE_CHAT_LIST, null);
            }
        }