Class Lidgren::Network::NetServer
ClassList > Lidgren > Network > NetServer
Specialized version of NetPeer used for "server" peers.
Inherits the following classes: Lidgren::Network::NetPeer
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 |
---|---|
NetServer (NetPeerConfiguration config) NetServer constructor. |
|
void | SendToAll (NetOutgoingMessage msg, NetDeliveryMethod method) Send a message to all connections. |
void | SendToAll (NetOutgoingMessage msg, NetDeliveryMethod method, int sequenceChannel) Send a message to all connections. |
void | SendToAll (NetOutgoingMessage msg, NetConnection except, NetDeliveryMethod method, int sequenceChannel) Send a message to all connections except one. |
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 Functions Documentation
function NetServer
function SendToAll [1/3]
Send a message to all connections.
inline void Lidgren::Network::NetServer::SendToAll (
NetOutgoingMessage msg,
NetDeliveryMethod method
)
Parameters:
msg
The message to sendmethod
How to deliver the message
function SendToAll [2/3]
Send a message to all connections.
inline void Lidgren::Network::NetServer::SendToAll (
NetOutgoingMessage msg,
NetDeliveryMethod method,
int sequenceChannel
)
Parameters:
msg
The message to sendmethod
How to deliver the messagesequenceChannel
Which sequence channel to use for the message
function SendToAll [3/3]
Send a message to all connections except one.
inline void Lidgren::Network::NetServer::SendToAll (
NetOutgoingMessage msg,
NetConnection except,
NetDeliveryMethod method,
int sequenceChannel
)
Parameters:
msg
The message to sendmethod
How to deliver the messageexcept
Don't send to this particular connectionsequenceChannel
Which sequence channel to use for the message
function ToString
The documentation for this class was generated from the following file api/unity-plugin/Scripts/Networking/Lidgren.Network/NetServer.cs