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
Show file Open project: Cyral/Bricklayer Class Usage Examples

Public Methods

Method 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

Method Description
Dispose ( bool disposing ) : void

Disposes the connection and shuts down the server

Method Details

Broadcast() public method

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
return void

BroadcastExcept() public method

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
return void

BroadcastExcept() public method

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
return void

CreateMessage() public method

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

Dispose() public method

Disposes the NetworkManager
public Dispose ( ) : void
return void

EncodeMessage() public method

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
return Lidgren.Network.NetOutgoingMessage

GetQuery() public method

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

Global() public method

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

ReadMessage() public method

Reads the latest message in the queue
public ReadMessage ( ) : NetIncomingMessage
return Lidgren.Network.NetIncomingMessage

Recycle() public method

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

Send() public method

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
return void

Send() public method

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
return void

Shutdown() public method

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

Start() public method

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