Example #1
0
 /// <summary>
 /// Handles MessageSent event of _communicationChannel object.
 /// 
 /// </summary>
 /// <param name="sender">Source of event</param><param name="e">Event arguments</param>
 private void CommunicationChannel_MessageSent(object sender, MessageEventArgs e)
 {
     this.OnMessageSent(e.Message);
 }
Example #2
0
        static void Client_MessageReceived(object sender, MessageEventArgs e)
        {
            var message = e.Message as ScsTextMessage;
            if (message == null)
            {
                return;
            }

            try
            {

                //trim the incoming message
                string[] trimMsg = message.ToString().Split(new Char[] { '&' });
                //foreach (string s in trimMsg)
                //{
                //if (s.Trim() != "")
                //    Log.WriteLine(LogLevel.Info,"-->" + s);
                //}
                //Log.WriteLine(LogLevel.Info, "rcv. 0: " + trimMsg[0]);
                Logger.WriteLine(LogState.Info, "rcv. 1: " + trimMsg[1]);
                Logger.WriteLine(LogState.Info, "rcv. 2: " + trimMsg[2]);
                Logger.WriteLine(LogState.Info, "rcv. 3: " + trimMsg[3]);

                //setup client for response message
                var client = (IScsServerClient)sender;
                int data = Convert.ToInt32(trimMsg[1]);

                switch (data)
                {
                    //LoginPacket
                    case (int)OpCode.LoginPacket:
                        Logger.WriteLine(LogState.Info, "Login Try: " + trimMsg[2]);
                        client.SendMessage(new ScsTextMessage(isLoginValid(trimMsg[2], trimMsg[3])));
                        break;
                    //RegisterPacket
                    case (int)OpCode.RegisterPacket:
                        Logger.WriteLine(LogState.Info, "Register Try: " + trimMsg[2]);
                        client.SendMessage(new ScsTextMessage(isRegisterValid(trimMsg[2], trimMsg[3])));
                        break;
                    default:
                        break;
                }
            }
            catch (Exception exception)
            {

                Logger.WriteLine(LogState.Exception, exception + "\n" + exception.StackTrace);
            }
        }
Example #3
0
 /// <summary>
 /// Handles MessageReceived event of _communicationChannel object.
 /// 
 /// </summary>
 /// <param name="sender">Source of event</param><param name="e">Event arguments</param>
 private void CommunicationChannel_MessageReceived(object sender, MessageEventArgs e)
 {
     IScsMessage message = e.Message;
     if (message is ScsPingMessage)
     {
         ICommunicationChannel communicationChannel = this._communicationChannel;
         ScsPingMessage scsPingMessage1 = new ScsPingMessage();
         scsPingMessage1.RepliedMessageId = message.MessageId;
         ScsPingMessage scsPingMessage2 = scsPingMessage1;
         communicationChannel.SendMessage((IScsMessage)scsPingMessage2);
     }
     else
         this.OnMessageReceived(message);
 }
Example #4
0
 /// <summary>
 /// Handles MessageReceived event of _communicationChannel object.
 /// 
 /// </summary>
 /// <param name="sender">Source of event</param><param name="e">Event arguments</param>
 private void CommunicationChannel_MessageReceived(object sender, MessageEventArgs e)
 {
     if (e.Message is ScsPingMessage)
         return;
     this.OnMessageReceived(e.Message);
 }