public MessageTransceiver(SlaveContext contextManager, int session) { this._slaveContext = contextManager; // 创建上行队列 _formatterType = contextManager.GetProperty <FormatterType>("EngineQueueFormat"); MessengerOption receiveOption = new MessengerOption(CoreConstants.UpLinkMQName, typeof(ControlMessage), typeof(DebugMessage), typeof(RmtGenMessage), typeof(StatusMessage), typeof(TestGenMessage)) { Type = contextManager.GetProperty <MessengerType>("MessengerType") }; _uplinkMessenger = Messenger.GetMessenger(receiveOption); // 创建下行队列 MessengerOption sendOption = new MessengerOption(CoreConstants.DownLinkMQName, typeof(ControlMessage), typeof(DebugMessage), typeof(RmtGenMessage), typeof(StatusMessage), typeof(TestGenMessage)) { Type = contextManager.GetProperty <MessengerType>("MessengerType") }; _downLinkMessenger = Messenger.GetMessenger(sendOption); _messageQueue = new LocalMessageQueue <MessageBase>(CoreConstants.DefaultEventsQueueSize); this.SessionId = session; }
public void SendMessage(MessageBase message) { _uplinkMessenger.Send(message, _slaveContext.GetProperty <FormatterType>("EngineQueueFormat"), message.GetType()); }