Click or drag to resize

NetPeer Class

Represents a local peer capable of holding zero, one or more connections to remote peers
Inheritance Hierarchy

Namespace:  Internal.Lidgren.Network
Assembly:  NeoAxis.Core (in NeoAxis.Core.dll) Version: 2024.1.1.0 (2024.1.1.0)
Syntax
C#
public class NetPeer

The NetPeer type exposes the following members.

Constructors
  NameDescription
Public methodNetPeer
NetPeer constructor
Top
Properties
  NameDescription
Public propertyConfiguration
Gets the configuration used to instanciate this NetPeer
Public propertyConnections
Gets a copy of the list of connections
Public propertyConnectionsCount
Gets the number of active connections
Public propertyMessageReceivedEvent
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.
Public propertyPort
Gets the port number this NetPeer is listening and sending on, if Start() has been called
Public propertySocket
Gets the socket, if Start() has been called
Public propertyStatistics
Statistics on this NetPeer since it was initialized
Public propertyStatus
Gets the NetPeerStatus of the NetPeer
Public propertyTag
Gets or sets the application defined object containing data about the peer
Public propertyUniqueIdentifier
Gets a unique identifier for this NetPeer based on Mac address and ip/port. Note! Not available until Start() has been called!
Public propertyUPnP
Returns an UPnP object if enabled in the NetPeerConfiguration
Top
Methods
  NameDescription
Public methodConnect(IPEndPoint)
Create a connection to a remote endpoint
Public methodConnect(IPEndPoint, NetOutgoingMessage)
Create a connection to a remote endpoint
Public methodConnect(String, Int32)
Create a connection to a remote endpoint
Public methodConnect(String, Int32, NetOutgoingMessage)
Create a connection to a remote endpoint
Public methodCreateMessage
Creates a new message for sending
Public methodCreateMessage(Int32)
Creates a new message for sending
Public methodCreateMessage(String)
Creates a new message for sending and writes the provided string to it
Public methodDiscoverKnownPeer(IPEndPoint)
Emit a discovery signal to a single known host
Public methodDiscoverKnownPeer(String, Int32)
Emit a discovery signal to a single known host
Public methodDiscoverLocalPeers
Emit a discovery signal to all hosts on your subnet
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodFlushSendQueue
If NetPeerConfiguration.AutoFlushSendQueue() is false; you need to call this to send all messages queued using SendMessage()
Public methodGetConnection
Get the connection, if any, for a certain remote endpoint
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodIntroduce
Send NetIntroduction to hostExternal and clientExternal; introducing client to host
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodRawSend
Send raw bytes; only used for debugging
Public methodReadMessage
Read a pending message from any connection, if any
Public methodReadMessage(NetIncomingMessage)
Reads a pending message from any connection, if any. Returns true if message was read, otherwise false.
Public methodReadMessages
Read a pending message from any connection, if any
Public methodRecycle(NetIncomingMessage)
Recycles a NetIncomingMessage instance for reuse; taking pressure off the garbage collector
Public methodRecycle(IEnumerableNetIncomingMessage)
Recycles a list of NetIncomingMessage instances for reuse; taking pressure off the garbage collector
Public methodRegisterReceivedCallback
Call this to register a callback for when a new message arrives
Public methodSendDiscoveryResponse
Send a discovery response message
Public methodSendMessage(NetOutgoingMessage, NetConnection, NetDeliveryMethod)
Send a message to a specific connection
Public methodSendMessage(NetOutgoingMessage, NetConnection, NetDeliveryMethod, Int32)
Send a message to a specific connection
Public methodSendMessage(NetOutgoingMessage, IListNetConnection, NetDeliveryMethod, Int32)
Send a message to a list of connections
Public methodSendUnconnectedMessage(NetOutgoingMessage, IListIPEndPoint)
Send a message to an unconnected host
Public methodSendUnconnectedMessage(NetOutgoingMessage, IPEndPoint)
Send a message to an unconnected host
Public methodSendUnconnectedMessage(NetOutgoingMessage, String, Int32)
Send a message to an unconnected host
Public methodSendUnconnectedToSelf
Send a message to this exact same netpeer (loopback)
Public methodShutdown
Disconnects all active connections and closes the socket
Public methodStart
Binds to socket and spawns the networking thread
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodUnregisterReceivedCallback
Call this to unregister a callback, but remember to do it in the same synchronization context!
Public methodWaitMessage
Read a pending message from any connection, blocking up to maxMillis if needed
Top
Extension Methods
See Also