예제 #1
0
        void Recv_Connect_Ans(System.IO.MemoryStream buffer)
        {
            string          json = System.Text.Encoding.UTF8.GetString(buffer.GetBuffer(), (int)buffer.Position, (int)(buffer.Length - buffer.Position));
            Msg_Connect_Ans ans  = JsonUtility.FromJson <Msg_Connect_Ans>(json);

            if (0 != ans.error_code)
            {
                Error(new Gamnet.Exception(ans.error_code, "fail to connect"));
                return;
            }
            _session_key   = ans.session_key;
            _session_token = ans.session_token;

            ConnectEvent evt = new ConnectEvent(this);

            _event_queue.Add(evt);             // already locked
        }
예제 #2
0
            public override void OnRecvMsg(System.IO.MemoryStream buffer)
            {
                string          json = System.Text.Encoding.UTF8.GetString(buffer.GetBuffer(), (int)buffer.Position, (int)buffer.Length);
                Msg_Connect_Ans ans  = JsonUtility.FromJson <Msg_Connect_Ans>(json);

                if (0 != ans.error_code)
                {
                    Debug.LogError("connect fail(error_code:" + ans.error_code + ")");
                    session.Error(new Gamnet.Exception(ErrorCode.ConnectFailError, "connect fail(error_code:" + ans.error_code + ")"));
                    return;
                }
                Debug.Log("recv connect ans(session_key:" + ans.session_key + ", session_token:" + ans.session_token + ")");
                session._session_key      = ans.session_key;
                session._session_token    = ans.session_token;
                session._connect_complete = true;

                ConnectEvent evt = new ConnectEvent(session);

                session._event_queue.Add(evt);                 // already locked
            }