public ActionResult Create(ReplySetup_M viewModel) { try { if (!ModelState.IsValid) { viewModel.ReplyMsgId = DateTime.Now.Random().ToString(); viewModel.ReplySetupId = DateTime.Now.Random().ToString(); ReplyMsg replymsg = new ReplyMsg(); replymsg.ReplyMsgId = viewModel.ReplySetupId; _repository.Add(viewModel.ToModel()); _ReplyMsg.Add(replymsg); // TODO: 这里编写添加逻辑 return(RedirectToAction("Index")); } else { InitForm("回复设置"); return(View(viewModel)); } } catch (Exception ex) { return(Alert("请联系开发人员\n" + ex.Message)); } }
public void Reply(MessageType type, int msgId, ArraySegment <byte> bufferSeg) { /* * FlatBufferBuilder fb = new FlatBufferBuilder(1); * var vec = ReplyMsg.CreateReplyMsg(fb, type, msgId, fb.CreateBuffVector(ReplyMsg.StartBuffVector, bufferSeg)); * fb.Finish(vec.Value); * */ var msg = ReplyMsg.CreateBuilder() .SetType(type) .SetMsgId(msgId) .SetBuff(ByteString.CopyFrom(bufferSeg.Array, 0, bufferSeg.Count)).Build(); var bytes = msg.ToByteArray(); Send(bytes, 0, bytes.Length); }
// Use this for initialization void OnReceiveMsg(byte[] bytes) { var msg = ReplyMsg.ParseFrom(bytes); //Debug.Log("receive message, type: " + msg.Type); if (msg.MsgId != -1) { var action = callbackQue.Dequeue(); action(msg.Buff); } else { var action = actionDict["Msg" + msg.Type.ToString()]; action(msg.Buff); } }