From 68db64980a394f91fa26c0dff1b0b82d950891f8 Mon Sep 17 00:00:00 2001 From: huinalam Date: Mon, 5 May 2014 02:00:48 +0900 Subject: [PATCH] Update NamedPipeServer.cs purpose that Send to a particular client. thx! :) --- NamedPipeWrapper/NamedPipeServer.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/NamedPipeWrapper/NamedPipeServer.cs b/NamedPipeWrapper/NamedPipeServer.cs index 7795a2a..680c789 100644 --- a/NamedPipeWrapper/NamedPipeServer.cs +++ b/NamedPipeWrapper/NamedPipeServer.cs @@ -96,6 +96,24 @@ public void PushMessage(TWrite message) } } } + + /// + /// Sends a message to all connected clients asynchronously. + /// This method returns immediately, possibly before the message has been sent to all clients. + /// + /// + /// Send to a Target client + public void PushMessage(TWrite message, string TargetCleintName) + { + if (TargetCleintName == null) + throw new ArgumentNullException("TargetCleintName is null"); + + var client = _connections.Where(p => p.Name == TargetCleintName).SingleOrDefault(); + if (client != null) + client.PushMessage(message); + else + throw new Exception("Is Not Exist TargetName"); + } /// /// Closes all open client connections and stops listening for new ones.