// 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); }
/// <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); }
/// <summary> /// parse the proto file to fill in the cbType combo box /// </summary> void UpdateTypeList() { cbType.Enabled = false; cbType.SelectedItem = null; cbType.Items.Clear(); if (File.Exists(ProtoFile)) { var list = new ProtoLoader(ProtoFile).LoadTypes() .OrderByName(true); cbType.Items.AddRange(list.ToArray()); cbType.Enabled = true; SetLastUsedType(); } }
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); } } }