Example #1
0
    // Update is called once per frame
    void protobufTest()
    {
        IpcCreateMapMsg msg = new IpcCreateMapMsg()
        {
            MapId = 10,
        };

        byte[]        outBytes = ProtoLoader.serializeProtoObject <IpcMsg>(msg);
        StringBuilder sb       = new StringBuilder();

        sb.Append("Out bytes = ");

        int cnt = outBytes.Length;

        for (int i = 0; i < cnt; ++i)
        {
            sb.Append(" ").Append(outBytes[i].ToString());
        }

        ConsoleEx.DebugLog(sb.ToString());


        IpcCreateMapMsg deser = ProtoLoader.deserializeProtoObj <IpcCreateMapMsg>(outBytes);

        ConsoleEx.DebugLog("Map Id = " + deser.MapId);
    }
Example #2
0
        /// <summary>
        /// 一直不停的接收信息, 在移动设备上一直不退出,但是在Editor上要退出
        /// </summary>
        void Client_ReceiveReady(object sender, NetMQSocketEventArgs e)
        {
            string msgTopicReceived = e.Socket.ReceiveString();

            byte[] msgReceived = e.Socket.Receive();

            OP     op  = (OP)Enum.Parse(typeof(OP), msgTopicReceived);
            IpcMsg msg = ProtoLoader.deserializeProtoObj(msgReceived, IpcMsg.Table[op]);

            ClientPool.OnReceive(msg);
        }