Class NetworkMessenger
Send and receive messages over a network connection.
Inherited Members
Namespace: HoloMetrix.Net.Remote
Assembly: HoloMetrix.Net.Remote.dll
Syntax
public class NetworkMessenger
Constructors
| Improve this Doc View SourceNetworkMessenger(NetworkStream)
Initializes a new instance of the NetworkMessenger class.
Declaration
public NetworkMessenger(NetworkStream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| NetworkStream | stream | The network stream. |
Properties
| Improve this Doc View SourceStream
Currently connected client.
Declaration
public NetworkStream Stream { get; }
Property Value
| Type | Description |
|---|---|
| NetworkStream |
Methods
| Improve this Doc View SourceSendMessage(string, byte[], bool, int)
Send a message to the client.
Declaration
public Response SendMessage(string command, byte[] data = null, bool waitForResponse = false, int waitForMilliseconds = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| string | command | The command message. |
| byte[] | data | Optional data package. |
| bool | waitForResponse | Whether or not to await a response. |
| int | waitForMilliseconds | The timeout in milliseconds. |
Returns
| Type | Description |
|---|---|
| Response |
SendMessageAsync(string, byte[], bool, int)
Send a message to the client.
Declaration
public Task<Response> SendMessageAsync(string command, byte[] data = null, bool waitForResponse = false, int waitForMilliseconds = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| string | command | The command message. |
| byte[] | data | Optional data package. |
| bool | waitForResponse | Whether or not to await a response. |
| int | waitForMilliseconds | The timeout in milliseconds. |
Returns
| Type | Description |
|---|---|
| Task<Response> | The message response. |
Events
| Improve this Doc View SourceConnectionLost
Event raised when the NetworkMessenger is closed.
Declaration
public event EventHandler ConnectionLost
Event Type
| Type | Description |
|---|---|
| EventHandler |
MessageReceived
Event raised when a new message is received.
Declaration
public event MessageReceivedEventHandler MessageReceived
Event Type
| Type | Description |
|---|---|
| MessageReceivedEventHandler |