示例#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);
    }
示例#2
0
        public void send(IpcMsg msg)
        {
            if (msg != null)
            {
                                #if DEBUG
                if (msg.op != OP.NpcMove)
                {
                    string plain = fastJSON.JSON.Instance.ToJSON(msg);
                    ConsoleEx.DebugLog("Sending message : " + msg.op.ToString() + "  " + plain, ConsoleEx.YELLOW);
                }
                                #endif

                if (isBinded)
                {
                    byte[] outBytes = ProtoLoader.serializeProtoObject <IpcMsg>(msg);
                    pubSocket.SendMore(msg.op.ToString()).Send(outBytes);
                }
            }
        }