/// <summary> /// Pushes a message to one specific client /// </summary> /// <param name="clientSessionId">Session ID of the client that should receive the message</param> /// <param name="message">The message to push</param> protected void PushMessageToClient(string clientSessionId, DuplexMessage message) { if (clients != null && clients.ContainsKey(clientSessionId)) { IUniversalDuplexCallbackContract ch = clients[clientSessionId]; IAsyncResult iar = ch.BeginSendToClient(message, new AsyncCallback(OnPushMessageComplete), new PushMessageState(ch, clientSessionId)); if (iar.CompletedSynchronously) { CompletePushMessage(iar); } } }
/// <summary> /// Pushes a message to one specific client /// </summary> /// <param name="clientSessionId">Session ID of the client that should receive the message</param> /// <param name="message">The message to push</param> protected void PushMessageToClient(string clientSessionId, DuplexMessage message) { try //try to send message to client if it is still connected. Otherwise dont worry about it. { IUniversalDuplexCallbackContract ch = (clients[clientSessionId]).Channel; IAsyncResult iar = ch.BeginSendToClient(message, new AsyncCallback(OnPushMessageComplete), new PushMessageState(ch, clientSessionId)); if (iar.CompletedSynchronously) { CompletePushMessage(iar); } } catch { } }