void client_MessageReceived(object sender, MessageEventArgs e)
 {
     lstMessageBox.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() =>
     {
         lstMessageBox.Items.Add(e.Message);
     }));
 }
Exemple #2
0
 private void OnMessageReceived(MessageEventArgs e)
 {
     EventHandler<MessageEventArgs> handler = this.MessageReceived;
     if (handler != null)
     {
         handler(this, e);
     }
 }
Exemple #3
0
 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);
     }
 }
Exemple #4
0
 private void connHandler_MessageReceived(object sender, MessageEventArgs e)
 {
     SMLogger.LogThis("Message received:" + e.Message);
     //this._messageParser.processMessage(e.Message);
     this.OnMessageReceived(e);
 }