C# Класс 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
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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

Приватные методы

Метод Описание
Dispose ( bool disposing ) : void

Disposes the connection and shuts down the server

Описание методов

Broadcast() публичный Метод

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
Результат void

BroadcastExcept() публичный Метод

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
Результат void

BroadcastExcept() публичный Метод

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
Результат void

CreateMessage() публичный Метод

Creates a NetOutgoingMessage from the interal Server object
public CreateMessage ( ) : NetOutgoingMessage
Результат Lidgren.Network.NetOutgoingMessage

Dispose() публичный Метод

Disposes the NetworkManager
public Dispose ( ) : void
Результат void

EncodeMessage() публичный Метод

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
Результат Lidgren.Network.NetOutgoingMessage

GetQuery() публичный Метод

Creates and returns a query for a client request, with info like MOTD, online players, etc
public GetQuery ( ) : Bricklayer.Client.Networking.ServerPingData
Результат Bricklayer.Client.Networking.ServerPingData

Global() публичный Метод

Sends a message to all players connected to the server
public Global ( IMessage gameMessage ) : void
gameMessage IMessage IMessage to send
Результат void

ReadMessage() публичный Метод

Reads the latest message in the queue
public ReadMessage ( ) : NetIncomingMessage
Результат Lidgren.Network.NetIncomingMessage

Recycle() публичный Метод

Recycles a message after processing by reusing it, reducing GC load
public Recycle ( NetIncomingMessage im ) : void
im Lidgren.Network.NetIncomingMessage Message to recylce
Результат void

Send() публичный Метод

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
Результат void

Send() публичный Метод

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
Результат void

Shutdown() публичный Метод

Shuts down the server and disconnects clients
public Shutdown ( string reason = "Shutting Down" ) : void
reason string Reason for shutting down
Результат void

Start() публичный Метод

Starts the server connection
public Start ( int port, int maxconnections ) : void
port int Port to run on
maxconnections int Maximum clients connectable
Результат void