Class Socketer
Sends and receives packets over the network, using the chosen protocol.
Namespace: Microsoft.MixedReality.SpectatorView
Assembly: cs.temp.dll.dll
Syntax
public class Socketer : MonoBehaviour
Fields
Direction
Whether this object should listen for incoming connections/packets, or send them. TCP Socketers are able to both send and recieve once a connection is intitiated.
Declaration
public SocketerClient.ProtocolDirection Direction
Field Value
| Type | Description |
|---|---|
| SocketerClient.ProtocolDirection |
Host
The IP address to connect to, if the Direction is Sender. Ignored if Listener.
Declaration
public string Host
Field Value
| Type | Description |
|---|---|
| String |
Port
The port to use. Suggested values are between 10000 and 40000, and must agree with the Socketer on the other end.
Declaration
public int Port
Field Value
| Type | Description |
|---|---|
| Int32 |
Protocol
The protocol to use: TCP or UDP.
Declaration
public SocketerClient.Protocol Protocol
Field Value
| Type | Description |
|---|---|
| SocketerClient.Protocol |
Methods
GetLocalIPAddress()
Gets the IP of this machine. Suitable for use as a Host on another Socketer.
Declaration
public static string GetLocalIPAddress()
Returns
| Type | Description |
|---|---|
| String |
SendNetworkMessage(Byte[])
Sends a byte array to the other side. Works for all Socketers except UDP Listeners. If the other Socketer is not listening, the messages are lost.
Declaration
public void SendNetworkMessage(byte[] message)
Parameters
| Type | Name | Description |
|---|---|---|
| Byte[] | message | Message contents. |
SendNetworkMessage(String)
Sends a byte array to the other side. Works for all Socketers except UDP Listeners. If the other Socketer is not listening, the messages are lost.
Declaration
public void SendNetworkMessage(string message)
Parameters
| Type | Name | Description |
|---|---|---|
| String | message | Message contents. |
Events
Connected
Fired when a TCP connection completes a connection. The string is the Host of the other Socketer. Note: this may fire on a thread other than the Update thread.
Declaration
public event Action<Socketer, int, string> Connected
Event Type
| Type | Description |
|---|---|
| Action<Socketer, Int32, String> |
Disconnected
Fired when a TCP connection loses a connection. The string is the Host of the other Socketer. Note: this may fire on a thread other than the Update thread.
Declaration
public event Action<Socketer, int, string> Disconnected
Event Type
| Type | Description |
|---|---|
| Action<Socketer, Int32, String> |
Message
Fired when a message arrives. Runs on the Update thread.
Declaration
public event Action<Socketer, MessageEvent> Message
Event Type
| Type | Description |
|---|---|
| Action<Socketer, MessageEvent> |