public ApplicationMessageHandler(IClientMessageHandlerProxy clientMessageHandlerProxy) { _ClientMessageHandlerProxy = clientMessageHandlerProxy; _ClientMessageHandlerProxy.MessageReceived += new EventHandler <MessageReceivedEventArgs>(_ClientMessageHandlerProxy_MessageReceived); _ClientMessageHandlerProxy.CommunicationStateChanged += new EventHandler <CommunicationStateChangedEventArgs>(_ClientMessageHandlerProxy_CommunicationStateChanged); }
void _ClientMessageHandlerProxy_MessageReceived(object sender, MessageReceivedEventArgs e) { IClientMessageHandlerProxy clientMessageHandlerProxy = sender as IClientMessageHandlerProxy; Message <MessageType> message = clientMessageHandlerProxy.DeserializeMessage <MessageType>(e.MessageBody); switch (message.MessageType) { case MessageType.RefreshApplicationDataRequest: if (this.RefreshApplicationDataRequest != null) { this.RefreshApplicationDataRequest(this, EventArgs.Empty); } break; } }
void _ClientMessageHandlerProxy_CommunicationStateChanged(object sender, CommunicationStateChangedEventArgs e) { IClientMessageHandlerProxy clientMessageHandlerProxy = sender as IClientMessageHandlerProxy; switch (e.CommunicationStatus) { case CommunicationStatus.Opened: // we have a connection, subscribe to web application events clientMessageHandlerProxy.Subscribe(WEB_APPLICATION_MESSAGE_ROUTING_KEY); if (this.CommunicationStateChanged != null) { this.CommunicationStateChanged(this, e); } break; } }