Exemplo n.º 1
0
        private void Receive_ServerSenddata(NetReceivePackage package)
        {
            scBroadcastIP mServerSendData = Protocol3Utility.getData <scBroadcastIP> (package.buffer.Array, package.buffer.Offset, package.buffer.Count);

            DebugSystem.Log("Client: " + mServerSendData.Ip);
            nReceiveCount++;
        }
Exemplo n.º 2
0
        /// <summary>
        /// 接收消息回调函数
        /// </summary>
        private void OnHandleHotfixMsg(NetReceivePackage package)
        {
            Type   msgType  = _msgTypes.GetValueByKey(package.Type);
            object instance = Activator.CreateInstance(msgType);
            var    message  = ProtobufHelper.Decode(instance, package.ProtoBodyData);

            Debug.Log($"Handle net message : {package.Type}");

            // TODO 可以在这里分发消息到逻辑层
            R2C_Login loginMsg = message as R2C_Login;

            if (loginMsg != null)
            {
                Debug.Log($"R2C_Login = {loginMsg.Address}");
                Debug.Log($"R2C_Login = {loginMsg.Key}");
            }
        }