C# Class MiniUDP.NetPeer

Datei anzeigen Open project: ashoulson/MiniUDP Class Usage Examples

Private Properties

Property Type Description
Connected void
Disconnected void
GenerateDrop byte
GenerateLoss byte
GeneratePing byte
GetFirstSequence ushort
GetTimeSinceRecv long
NetPeer System
OnNotificationReceived void
OnPayloadReceived void
OnPeerClosed void
OnPeerConnected void
OnReceiveCarrier void
OnReceiveNotification bool
OnReceiveOther void
OnReceivePayload bool
OnReceivePing void
OnReceivePong void
QueueNotification bool
SetCore void
Update void

Public Methods

Method Description
Close ( byte userReason = NetConfig.DEFAULT_USER_REASON ) : void

Closes the peer's network connection for a given reason byte.

QueueNotification ( byte data, ushort length ) : bool

Queues a reliable ordered notification for delivery.

SendPayload ( byte data, ushort length ) : SocketError

Immediately sends an unreliable sequenced payload.

Private Methods

Method Description
Connected ( ) : void

Make sure this is called before exposing the peer to the main thread.

Disconnected ( ) : void
GenerateDrop ( ) : byte

Returns the statistics on dropped packets.

GenerateLoss ( ) : byte

Returns the statistics on lost packets.

GeneratePing ( long curTime ) : byte

Advances the outgoing ping sequence.

GetFirstSequence ( ) : ushort

If we have outgoing notifications, returns the sequence of the first.

GetTimeSinceRecv ( long curTime ) : long

Returns the time (in ms) since we last received useful data.

NetPeer ( IPEndPoint endPoint, string token, bool isClient, long creationTick ) : System
OnNotificationReceived ( byte data, int dataLength ) : void
OnPayloadReceived ( byte data, int dataLength ) : void
OnPeerClosed ( NetCloseReason reason, byte userKickReason, SocketError error ) : void
OnPeerConnected ( ) : void
OnReceiveCarrier ( long curTime, ushort notificationAck, Action deallocate ) : void

Cleans out any notifications older than the received carrier ack.

OnReceiveNotification ( long curTime, ushort notificationSeq ) : bool

Processes a notification and updates our ack counter. Return true iff the notification is new.

OnReceiveOther ( long curTime ) : void

Records the fact that we've received data.

OnReceivePayload ( long curTime, ushort sequence ) : bool

Logs the payload's sequence ID to record payload packet loss. Returns true if we should accept the payload, false if it's too old.

OnReceivePing ( long curTime, byte loss ) : void

Processes statistics received from pong packets.

OnReceivePong ( long curTime, byte pongSeq, byte drop ) : void

Processes statistics received from pong packets.

QueueNotification ( NetEvent data ) : bool

Queues a new notification to be send out reliably during ticks.

SetCore ( NetCore core ) : void
Update ( long curTime ) : void

Method Details

Close() public method

Closes the peer's network connection for a given reason byte.
public Close ( byte userReason = NetConfig.DEFAULT_USER_REASON ) : void
userReason byte
return void

QueueNotification() public method

Queues a reliable ordered notification for delivery.
public QueueNotification ( byte data, ushort length ) : bool
data byte
length ushort
return bool

SendPayload() public method

Immediately sends an unreliable sequenced payload.
public SendPayload ( byte data, ushort length ) : SocketError
data byte
length ushort
return SocketError