/// <summary>Return a response for the message</summary> /// <param name="msg">The message link to this response</param> /// <returns>The response to the message</returns> public ISpEventMessage Response(ISpEventMessage msg) { DemoMsgId id = SpConverter.IntToEnum <DemoMsgId>(msg.EventId); DemoMsgType _type = SpConverter.IntToEnum <DemoMsgType>(msg.TypeId); // Only one type of message for now. // Responses also in the same enum as messages so have to handle switch (_type) { case DemoMsgType.SimpleMsg: // TODO Hmm should this be a response instead of a message? return(new DemoMsgBase(_type, id, msg.Priority) { ReturnCode = msg.ReturnCode, StringPayload = msg.StringPayload, ReturnStatus = msg.ReturnStatus, // You can add any other info from derived message }); case DemoMsgType.SimpleResponse: throw new Exception(string.Format("Response '{0}' is not a valid message", _type)); default: throw new Exception(string.Format("Unhandled message '{0}'", _type)); } }
//public void StartEngine() { // this.stateMachineEngine.Start(); //} //public void StopEngine() { // this.stateMachineEngine.Stop(); //} public void SendMsg(DemoMsgId id) { DummyDI.EventListnerInstance.PostMessage(new DemoMsgBase(DemoMsgType.SimpleMsg, id)); }