HavenDV / H.Pipes

A simple, easy to use, strongly-typed, async wrapper around .NET named pipes.
MIT License
242 stars 26 forks source link

Feature request: Have a connection identifier on the server based on a client connection #25

Open PeterPann23 opened 2 years ago

PeterPann23 commented 2 years ago

When establishing a connection it would be nice if one could add client metadata to the connection like a Connection Identifier (CID). At the moment it's hard to identify a client connection on the server side. At the moment we make this part of the message but if the server gets a client message and needs to "send updates to a specific other" connected client then having a CID would be good.

await using var client = new PipeClient(pipeName) { ClientMeta = new ClientMeta() { MachineName=Enviroment.MachineName, Role="MyRole", ...} };

One could add the CID in the server connection handshake, the service already maintains a state for connected clients

When implementing something like this, you could do: await server.ConnectedClients.Where(w=>s.MetaData.Role=="SomeRole").SendMsgAsync(..)

HavenDV commented 2 years ago

Maybe this will work for you? https://github.com/HavenDV/H.Pipes/blob/468aa10a02c1cbc6035e2f7c23e44720ae6a0424/src/libs/H.Pipes/PipeConnection.cs#L190-L198

PeterPann23 commented 2 years ago

That doesn’t solve the issue I have, better is add a strong named CID that both client and server can agree on and is unique to both

kaddrison commented 1 year ago

Was this every done? - I have 2 apps on the same machine sending to the server - which is OK for the message as I can put the app in it but I can't monitor the disconnect connect as I don't get which app - I can send a message on connect but I can't monitor disconnect