Manages a connection between a server and a client. PipesServer creates one for each client and passes it to its ClientConnected, ClientDisconnected and ClientMessage events.
Constructors
Properties
| Identifier | Type | Description |
|---|
| ID | int | Numeric identifier. A read-only field. |
| IsConnected | bool | Indicates if stream is connected. |
| Name | string | String identifier for the client in this connected stream. |
| TheStream | PipeStream | The stream between server and client. |
Events
| Identifier | Type | Description |
|---|
| Disconnected | PipeConnectionEvent | Indicates the stream has been disconnected. |
| Error | PipeConnectionExceptionEvent | Indicates an error. |
| ReceiveMessage | PipeConnectionMessageEvent | Indicates that the stream received a message. |
Methods
Delegates
| Delegate | Returns | Description |
|---|
| PipeConnectionEvent(PipesConnection pc) | void | Handles a connection state event, such as disconnection. |
| PipeConnectionMessageEvent(PipesConnection pc, PipeMessage message) | void | Handles a message received on a connection. |
| PipeConnectionExceptionEvent(PipesConnection pc, Exception ex) | void | Handles an error on a connection. |
Example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| using Nova.IPC.Pipes;
PipesServer server = new PipesServer("NovaDemoServer");
// The server passes each client's PipesConnection to its events.
server.ClientConnected += connection =>
{
Console.WriteLine(connection.Name + " connected: " + connection.IsConnected);
PipeMessage welcome = new PipeMessage();
welcome.EncodeString("Welcome.");
connection.Send(welcome);
};
server.Start();
|