예제 #1
0
        private void HandshakeCallBack(IExtensible msgData)
        {
            Handshake handshake = (Handshake)msgData;
            string    token     = handshake.token;

            Debug.Log("HandshakeCallBack" + token);
            if (token == NetUtilcs.HANDLESHAKE_2)
            {
                Handshake reponse = new Handshake
                {
                    token = NetUtilcs.HANDLESHAKE_3
                };
                NetManager.SendMsg(ProtoDefine.Handshake, reponse);
                handleShakeState = HandleShakeState.SERVER_REPLY_CLIENT;
            }
            else if (token == NetUtilcs.HANDLESHAKE_4)
            {
                //验证结束,请求登录服务器
                handleShakeState = HandleShakeState.HANDLESHAKE_SUCCEED;
                Debug.Log("握手成功");
            }
            else
            {
                Debug.LogError("握手失败,非目标服务");
            }
        }
예제 #2
0
        public void Initialize()
        {
            NetManager.ListenerMsg(ProtoDefine.Handshake, HandshakeCallBack);

            handleShakeState = HandleShakeState.CLIENT_CALL_SERVER;
        }