void client_MessageReceived(object sender, MessageEventArgs e) { lstMessageBox.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => { lstMessageBox.Items.Add(e.Message); })); }
private void OnMessageReceived(MessageEventArgs e) { EventHandler<MessageEventArgs> handler = this.MessageReceived; if (handler != null) { handler(this, e); } }
private void msgProc_MessageReceived(object sender, MessageEventArgs e) { if(_protocol == null) _protocol = new ProtocolBase(this); try { // not really optimal, better use a hashtable here - with integer keys switch (e.Message.GetType().Name) { case "TestRequest": var testRequest = (TestRequest)e.Message; _msgProc.Send(new TestResponse { Message = "Well hello to you too!", Number = testRequest.Number }); break; case "ProtocolVersionResponse": var protocolVersion = (ProtocolVersionResponse)e.Message; // todo: use factory pattern here to get the proper protocol version _protocol = new ProtocolBase(this); _msgProc.Send(new ACKResponse(protocolVersion.Id)); break; default: // if it's not handled by the session, pass it to the Protocol _protocol.ProcessMessage(e.Message); break; } } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
private void connHandler_MessageReceived(object sender, MessageEventArgs e) { SMLogger.LogThis("Message received:" + e.Message); //this._messageParser.processMessage(e.Message); this.OnMessageReceived(e); }