private static void ClientOnMessageSent(object sender, MessageEventArgs args) { var textMessage = args.Message as TextMessage; if (textMessage != null) { Console.WriteLine("SENT: {0}", textMessage.Text); } else { Console.WriteLine("SENT: {0}", args.Message.GetType()); } }
protected override void ClientOnMessageSent(object sender, MessageEventArgs args) { base.ClientOnMessageSent(sender, args); var client = sender as IServerClient; if (client == null) { throw new ArgumentNullException("sender", "Internal server error - sender-client can not be null"); } // Simple debug var textMessage = args.Message as TextMessage; if (textMessage != null) { ServerConsole.DebugLine("[{0}] SENT: {1}", client.RemoteEndPoint, textMessage.Text); } else { ServerConsole.DebugLine("[{0}] SENT: {1}", client.RemoteEndPoint, args.Message.GetType()); } }
/// <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) { OnMessageSent(e.Message); }
/// <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 PingMessage) { return; } OnMessageReceived(e.Message); }
/// <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) { var message = e.Message; if (message is PingMessage) { _communicationChannel.SendMessage(new PingMessage { RepliedId = message.Id }); return; } OnMessageReceived(message); }
protected virtual void ClientOnMessageSent(object sender, MessageEventArgs args) { }