Class Lidgren::Network::NetPeer
ClassList > Lidgren > Network > NetPeer
Represents a local peer capable of holding zero, one or more connections to remote peers.
Inherited by the following classes: Lidgren::Network::NetClient, Lidgren::Network::NetServer
Public Properties
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 |
---|---|
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 Configuration
property Connections
property ConnectionsCount
property MessageReceivedEvent
property Port
property Socket
property Statistics
property Status
property Tag
property UPnP
property UniqueIdentifier
Public Functions Documentation
function Connect [1/4]
function Connect [2/4]
inline NetConnection Lidgren::Network::NetPeer::Connect (
string host,
int port,
NetOutgoingMessage hailMessage
)
function Connect [3/4]
function Connect [4/4]
inline virtual NetConnection Lidgren::Network::NetPeer::Connect (
NetEndPoint remoteEndPoint,
NetOutgoingMessage hailMessage
)
function CreateMessage [1/3]
function CreateMessage [2/3]
function CreateMessage [3/3]
Creates a new message for sending.
Parameters:
initialCapacity
initial capacity in bytes
function DiscoverKnownPeer [1/2]
function DiscoverKnownPeer [2/2]
function DiscoverLocalPeers
function FlushSendQueue
function GetConnection
function Introduce
inline void Lidgren::Network::NetPeer::Introduce (
NetEndPoint hostInternal,
NetEndPoint hostExternal,
NetEndPoint clientInternal,
NetEndPoint clientExternal,
string token
)
function NetPeer
function RawSend
inline void Lidgren::Network::NetPeer::RawSend (
byte[] arr,
int offset,
int length,
NetEndPoint destination
)
function ReadMessage [1/2]
function ReadMessage [2/2]
Reads a pending message from any connection, if any. Returns true if message was read, otherwise false.
Returns:
True, if message was read.
function ReadMessages
function Recycle [1/4]
function Recycle [2/4]
function RegisterReceivedCallback
inline void Lidgren::Network::NetPeer::RegisterReceivedCallback (
SendOrPostCallback callback,
SynchronizationContext syncContext=null
)
function SendDiscoveryResponse
inline void Lidgren::Network::NetPeer::SendDiscoveryResponse (
NetOutgoingMessage msg,
NetEndPoint recipient
)
function SendMessage [1/3]
Send a message to a specific connection.
inline NetSendResult Lidgren::Network::NetPeer::SendMessage (
NetOutgoingMessage msg,
NetConnection recipient,
NetDeliveryMethod method
)
Parameters:
msg
The message to sendrecipient
The recipient connectionmethod
How to deliver the message
function SendMessage [2/3]
Send a message to a specific connection.
inline NetSendResult Lidgren::Network::NetPeer::SendMessage (
NetOutgoingMessage msg,
NetConnection recipient,
NetDeliveryMethod method,
int sequenceChannel
)
Parameters:
msg
The message to sendrecipient
The recipient connectionmethod
How to deliver the messagesequenceChannel
Sequence channel within the delivery method
function SendMessage [3/3]
Send a message to a list of connections.
inline void Lidgren::Network::NetPeer::SendMessage (
NetOutgoingMessage msg,
IList< NetConnection > recipients,
NetDeliveryMethod method,
int sequenceChannel
)
Parameters:
msg
The message to sendrecipients
The list of recipients to send tomethod
How to deliver the messagesequenceChannel
Sequence channel within the delivery method
function SendUnconnectedMessage [1/3]
inline void Lidgren::Network::NetPeer::SendUnconnectedMessage (
NetOutgoingMessage msg,
string host,
int port
)
function SendUnconnectedMessage [2/3]
inline void Lidgren::Network::NetPeer::SendUnconnectedMessage (
NetOutgoingMessage msg,
NetEndPoint recipient
)
function SendUnconnectedMessage [3/3]
inline void Lidgren::Network::NetPeer::SendUnconnectedMessage (
NetOutgoingMessage msg,
IList< NetEndPoint > recipients
)
function SendUnconnectedToSelf
function Shutdown
function Start
function UnregisterReceivedCallback
function WaitMessage
The documentation for this class was generated from the following file api/unity-plugin/Scripts/Networking/Lidgren.Network/NetNatIntroduction.cs