Class Lidgren::Network::NetClient
ClassList > Lidgren > Network > NetClient
Specialized version of NetPeer used for a "client" connection. It does not accept any incoming connections and maintains a ServerConnection property.
Inherits the following classes: Lidgren::Network::NetPeer
Public Properties
Type | Name |
---|---|
property NetConnectionStatus | ConnectionStatus Gets the connection status of the server connection (or NetConnectionStatus.Disconnected if no connection) |
property NetConnection | ServerConnection Gets the connection to the server, if any. |
Public Properties inherited from Lidgren::Network::NetPeer
Type | Name |
---|---|
property NetPeerConfiguration | Configuration Gets the configuration used to instanciate this NetPeer. |
property List< NetConnection > | Connections Gets a copy of the list of connections. |
property int | ConnectionsCount Gets the number of active connections. |
property AutoResetEvent | MessageReceivedEvent Signalling event which can be waited on to determine when a message is queued for reading. Note that there is no guarantee that after the event is signaled the blocked thread will find the message in the queue. Other user created threads could be preempted and dequeue the message before the waiting thread wakes up. |
property int | Port Gets the port number this NetPeer is listening and sending on, if Start() has been called. |
property Socket | Socket Gets the socket, if Start() has been called. |
property NetPeerStatistics | Statistics Statistics on this NetPeer since it was initialized. |
property NetPeerStatus | Status Gets the NetPeerStatus of the NetPeer. |
property object | Tag Gets or sets the application defined object containing data about the peer. |
property NetUPnP | UPnP Returns an UPnP object if enabled in the NetPeerConfiguration. |
property long | UniqueIdentifier Gets a unique identifier for this NetPeer based on Mac address and ip/port. Note! Not available until Start() has been called! |
Public Functions
Type | Name |
---|---|
virtual override NetConnection | Connect (NetEndPoint remoteEndPoint, NetOutgoingMessage hailMessage) Connect to a remote server. |
void | Disconnect (string byeMessage) Disconnect from server. |
NetClient (NetPeerConfiguration config) NetClient constructor. |
|
NetSendResult | SendMessage (NetOutgoingMessage msg, NetDeliveryMethod method) Sends message to server. |
NetSendResult | SendMessage (NetOutgoingMessage msg, NetDeliveryMethod method, int sequenceChannel) Sends message to server. |
override string | ToString () Returns a string that represents this object. |
Public Functions inherited from Lidgren::Network::NetPeer
Type | Name |
---|---|
NetConnection | Connect (string host, int port) Create a connection to a remote endpoint. |
NetConnection | Connect (string host, int port, NetOutgoingMessage hailMessage) Create a connection to a remote endpoint. |
NetConnection | Connect (NetEndPoint remoteEndPoint) Create a connection to a remote endpoint. |
virtual NetConnection | Connect (NetEndPoint remoteEndPoint, NetOutgoingMessage hailMessage) Create a connection to a remote endpoint. |
NetOutgoingMessage | CreateMessage () Creates a new message for sending. |
NetOutgoingMessage | CreateMessage (string content) Creates a new message for sending and writes the provided string to it. |
NetOutgoingMessage | CreateMessage (int initialCapacity) Creates a new message for sending. |
bool | DiscoverKnownPeer (string host, int serverPort) Emit a discovery signal to a single known host. |
void | DiscoverKnownPeer (NetEndPoint endPoint) Emit a discovery signal to a single known host. |
void | DiscoverLocalPeers (int serverPort) Emit a discovery signal to all hosts on your subnet. |
void | FlushSendQueue () If NetPeerConfiguration.AutoFlushSendQueue() is false; you need to call this to send all messages queued using SendMessage() |
NetConnection | GetConnection (NetEndPoint ep) Get the connection, if any, for a certain remote endpoint. |
void | Introduce (NetEndPoint hostInternal, NetEndPoint hostExternal, NetEndPoint clientInternal, NetEndPoint clientExternal, string token) Send NetIntroduction to hostExternal and clientExternal; introducing client to host. |
NetPeer (NetPeerConfiguration config) NetPeer constructor. |
|
void | RawSend (byte[] arr, int offset, int length, NetEndPoint destination) Send raw bytes; only used for debugging. |
NetIncomingMessage | ReadMessage () Read a pending message from any connection, if any. |
bool | ReadMessage (out NetIncomingMessage message) Reads a pending message from any connection, if any. Returns true if message was read, otherwise false. |
int | ReadMessages (IList< NetIncomingMessage > addTo) Read a pending message from any connection, if any. |
void | Recycle (NetIncomingMessage msg) Recycles a NetIncomingMessage instance for reuse; taking pressure off the garbage collector. |
void | Recycle (IEnumerable< NetIncomingMessage > toRecycle) Recycles a list of NetIncomingMessage instances for reuse; taking pressure off the garbage collector. |
void | RegisterReceivedCallback (SendOrPostCallback callback, SynchronizationContext syncContext=null) Call this to register a callback for when a new message arrives. |
void | SendDiscoveryResponse (NetOutgoingMessage msg, NetEndPoint recipient) Send a discovery response message. |
NetSendResult | SendMessage (NetOutgoingMessage msg, NetConnection recipient, NetDeliveryMethod method) Send a message to a specific connection. |
NetSendResult | SendMessage (NetOutgoingMessage msg, NetConnection recipient, NetDeliveryMethod method, int sequenceChannel) Send a message to a specific connection. |
void | SendMessage (NetOutgoingMessage msg, IList< NetConnection > recipients, NetDeliveryMethod method, int sequenceChannel) Send a message to a list of connections. |
void | SendUnconnectedMessage (NetOutgoingMessage msg, string host, int port) Send a message to an unconnected host. |
void | SendUnconnectedMessage (NetOutgoingMessage msg, NetEndPoint recipient) Send a message to an unconnected host. |
void | SendUnconnectedMessage (NetOutgoingMessage msg, IList< NetEndPoint > recipients) Send a message to an unconnected host. |
void | SendUnconnectedToSelf (NetOutgoingMessage om) Send a message to this exact same netpeer (loopback) |
void | Shutdown (string bye) Disconnects all active connections and closes the socket. |
void | Start () Binds to socket and spawns the networking thread. |
void | UnregisterReceivedCallback (SendOrPostCallback callback) Call this to unregister a callback, but remember to do it in the same synchronization context! |
NetIncomingMessage | WaitMessage (int maxMillis) Read a pending message from any connection, blocking up to maxMillis if needed. |
Public Properties Documentation
property ConnectionStatus
property ServerConnection
Public Functions Documentation
function Connect
Connect to a remote server.
inline virtual override NetConnection Lidgren::Network::NetClient::Connect (
NetEndPoint remoteEndPoint,
NetOutgoingMessage hailMessage
)
Parameters:
remoteEndPoint
The remote endpoint to connect tohailMessage
The hail message to pass
Returns:
server connection, or null if already connected
Implements Lidgren::Network::NetPeer::Connect
function Disconnect
Disconnect from server.
Parameters:
byeMessage
reason for disconnect
function NetClient
NetClient constructor.
Parameters:
config
function SendMessage [1/2]
inline NetSendResult Lidgren::Network::NetClient::SendMessage (
NetOutgoingMessage msg,
NetDeliveryMethod method
)
function SendMessage [2/2]
inline NetSendResult Lidgren::Network::NetClient::SendMessage (
NetOutgoingMessage msg,
NetDeliveryMethod method,
int sequenceChannel
)
function ToString
The documentation for this class was generated from the following file api/unity-plugin/Scripts/Networking/Lidgren.Network/NetClient.cs