C# Class Bricklayer.Server.NetworkManager

Handles network functions for the server, such as port-forwarding, sending messages, etc Send Function Guide: Send: Sends a message to a player Broadcast: Sends a message to each player in a map Global: Sends a message to each player on the server
Afficher le fichier Open project: Cyral/Bricklayer Class Usage Examples

Méthodes publiques

Méthode Description
Broadcast ( Map map, IMessage gameMessage ) : void

Broadcasts a message to all players in a room

BroadcastExcept ( IMessage gameMessage, Bricklayer.Server.Entities.Player player ) : void

Broadcasts a message to all players in a room, EXCEPT for the one specified

BroadcastExcept ( IMessage gameMessage, NetConnection recipient ) : void

Broadcasts a message to all clients in a room, EXCEPT for the one specified

CreateMessage ( ) : NetOutgoingMessage

Creates a NetOutgoingMessage from the interal Server object

Dispose ( ) : void

Disposes the NetworkManager

EncodeMessage ( IMessage gameMessage ) : NetOutgoingMessage

Encodes a message with a packet ID so the client can identify what kind of message it is

GetQuery ( ) : Bricklayer.Client.Networking.ServerPingData

Creates and returns a query for a client request, with info like MOTD, online players, etc

Global ( IMessage gameMessage ) : void

Sends a message to all players connected to the server

ReadMessage ( ) : NetIncomingMessage

Reads the latest message in the queue

Recycle ( NetIncomingMessage im ) : void

Recycles a message after processing by reusing it, reducing GC load

Send ( IMessage gameMessage, Bricklayer.Server.Entities.Player player ) : void

Encodes and sends a message to a specified player

Send ( IMessage gameMessage, NetConnection recipient ) : void

Encodes and sends a message to a specified NetConnection recipient

Shutdown ( string reason = "Shutting Down" ) : void

Shuts down the server and disconnects clients

Start ( int port, int maxconnections ) : void

Starts the server connection

Private Methods

Méthode Description
Dispose ( bool disposing ) : void

Disposes the connection and shuts down the server

Method Details

Broadcast() public méthode

Broadcasts a message to all players in a room
public Broadcast ( Map map, IMessage gameMessage ) : void
map Bricklayer.Client.World.Map Map/Room to send to
gameMessage IMessage IMessage to send
Résultat void

BroadcastExcept() public méthode

Broadcasts a message to all players in a room, EXCEPT for the one specified
public BroadcastExcept ( IMessage gameMessage, Bricklayer.Server.Entities.Player player ) : void
gameMessage IMessage IMessage to send
player Bricklayer.Server.Entities.Player Player NOT to send to
Résultat void

BroadcastExcept() public méthode

Broadcasts a message to all clients in a room, EXCEPT for the one specified
public BroadcastExcept ( IMessage gameMessage, NetConnection recipient ) : void
gameMessage IMessage IMessage to send
recipient Lidgren.Network.NetConnection Client NOT to send to
Résultat void

CreateMessage() public méthode

Creates a NetOutgoingMessage from the interal Server object
public CreateMessage ( ) : NetOutgoingMessage
Résultat Lidgren.Network.NetOutgoingMessage

Dispose() public méthode

Disposes the NetworkManager
public Dispose ( ) : void
Résultat void

EncodeMessage() public méthode

Encodes a message with a packet ID so the client can identify what kind of message it is
public EncodeMessage ( IMessage gameMessage ) : NetOutgoingMessage
gameMessage IMessage A message to encode
Résultat Lidgren.Network.NetOutgoingMessage

GetQuery() public méthode

Creates and returns a query for a client request, with info like MOTD, online players, etc
public GetQuery ( ) : Bricklayer.Client.Networking.ServerPingData
Résultat Bricklayer.Client.Networking.ServerPingData

Global() public méthode

Sends a message to all players connected to the server
public Global ( IMessage gameMessage ) : void
gameMessage IMessage IMessage to send
Résultat void

ReadMessage() public méthode

Reads the latest message in the queue
public ReadMessage ( ) : NetIncomingMessage
Résultat Lidgren.Network.NetIncomingMessage

Recycle() public méthode

Recycles a message after processing by reusing it, reducing GC load
public Recycle ( NetIncomingMessage im ) : void
im Lidgren.Network.NetIncomingMessage Message to recylce
Résultat void

Send() public méthode

Encodes and sends a message to a specified player
public Send ( IMessage gameMessage, Bricklayer.Server.Entities.Player player ) : void
gameMessage IMessage IMessage to send
player Bricklayer.Server.Entities.Player Player to send to
Résultat void

Send() public méthode

Encodes and sends a message to a specified NetConnection recipient
public Send ( IMessage gameMessage, NetConnection recipient ) : void
gameMessage IMessage IMessage to send
recipient Lidgren.Network.NetConnection Client to send to
Résultat void

Shutdown() public méthode

Shuts down the server and disconnects clients
public Shutdown ( string reason = "Shutting Down" ) : void
reason string Reason for shutting down
Résultat void

Start() public méthode

Starts the server connection
public Start ( int port, int maxconnections ) : void
port int Port to run on
maxconnections int Maximum clients connectable
Résultat void