public GameUtil.Network.Message MakeResponse(GameUtil.Network.Message request) { switch (request.MessageType) { case DMCheckMessage.MESSAGE_TYPE: { if (_isDM) { var msg = (DMCheckMessage)request; _dmCheckForm.SetMessage(msg.text); connectionTimer.Enabled = false; var dialogResult = _dmCheckForm.ShowDialog(); connectionTimer.Enabled = true; var resp = new DMCheckResultMessage(); resp.result = dialogResult == DialogResult.Yes; return(resp); } } break; case UserDeterminMessage.MESSAGE_TYPE: { var msg = (UserDeterminMessage)request; _userCheckForm.SetMessage(msg.text); connectionTimer.Enabled = false; _userCheckForm.ShowDialog(); connectionTimer.Enabled = true; var resp = new UserDeterminResultMessage(); resp.result = _userCheckForm.ReturnValue; return(resp); } default: break; } return(null); }
public event EventHandler<NetworkEventCaughtEventArgs> EventCaught; // multiple threads would invoke public abstract void SendMessage(Message message);
public void Request(Message message, Action<Message> callback) { var identifiedMsg = new IdentifiedMessage(message); while (_callbackDict.ContainsKey(identifiedMsg.guid)) identifiedMsg.guid = Guid.NewGuid(); _callbackDict.Add(identifiedMsg.guid, callback); SendMessage(identifiedMsg); }
public IdentifiedMessage(Message message) { this.innerMessage = message; this.guid = Guid.NewGuid(); this.resp = false; }