C# Класс BeardedManStudios.Network.Networking

Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
RunActionsInFixedLoop bool

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

Метод Описание
ChangeClientScene ( BeardedManStudios.Network.NetWorker netWorker, NetworkingPlayer targetPlayer, string sceneName ) : void

Tells the client to change their scene to the given scene. This is often called after the server has changed to that scene to ensure that the server will always load up the scene before the client does

ChangeClientScene ( BeardedManStudios.Network.NetWorker netWorker, string sceneName ) : void

Tells the client to change their scene to the given scene. This is often called after the server has changed to that scene to ensure that the server will always load up the scene before the client does

ChangeClientScene ( ushort port, NetworkingPlayer targetPlayer, string sceneName ) : void

Tells the client to change their scene to the given scene. This is often called after the server has changed to that scene to ensure that the server will always load up the scene before the client does

ChangeClientScene ( ushort port, string sceneName ) : void

Tells the client to change their scene to the given scene. This is often called after the server has changed to that scene to ensure that the server will always load up the scene before the client does

ClientReady ( BeardedManStudios.Network.NetWorker socket ) : void
Connect ( string ip, ushort port, TransportationProtocolType comType, bool winRT = false, bool useNat = false, bool standAlone = false ) : BeardedManStudios.Network.NetWorker

Create and connect a client to the specified server ip and port

Destroy ( SimpleNetworkedMonoBehavior netBehavior ) : void

Destroy a simple networked object

Disconnect ( ) : void

Disconnects all sockets and clients for this machine running under this system and removes them all from the lookup (calls Networking.NetworkingReset

Disconnect ( BeardedManStudios.Network.NetWorker socket ) : void

Disconnect the specified NetWorker (socket) and remove it from the Networking.Sockets lookup

Disconnect ( BeardedManStudios.Network.NetWorker socket, NetworkingPlayer player ) : void

Disconnect a player on a given NetWorker(Socket)

Disconnect ( ushort port ) : void

Disconnects (on this machine) either a client or a server on the specified port

Disconnect ( ushort port, NetworkingPlayer player ) : void

Disconnects a player on a given port

DynamicCommand ( BeardedManStudios.Network.NetWorker socket, string command, bool relayOnServer = true, bool reliable = true ) : void
GetLocalIPAddress ( ) : string

Get the local Ip address

Host ( ushort port, TransportationProtocolType comType, int maxConnections, bool winRT = false, string overrideIP = null, bool allowWebplayerConnection = false, bool relayToAll = true, bool useNat = false, BeardedManStudios.Network.NetWorker errorCallback = null ) : BeardedManStudios.Network.NetWorker

Will setup a new server on this machine

InitializeFirewallCheck ( ushort port ) : void

This will force a firewall request by the users machine to allow for network communications with this particular application

Instantiate ( GameObject obj, NetworkReceivers receivers = NetworkReceivers.All, Action callback = null ) : void

Instantiate an object on the network

Instantiate ( GameObject obj, Vector3 position, Quaternion rotation, NetworkReceivers receivers = NetworkReceivers.All, Action callback = null ) : void

Instantiate an object on the network

Instantiate ( string obj, NetworkReceivers receivers, Action callback = null ) : void

Instantiate an object on the network

Instantiate ( string obj, Vector3 position, Quaternion rotation, NetworkReceivers receivers, Action callback = null ) : void

Instantiate an object on the network

InstantiateFromResources ( string resourcePath, NetworkReceivers receivers = NetworkReceivers.All, Action callback = null ) : void

Instantiate an object on the network from the resources folder

InstantiateFromResources ( string resourcePath, Vector3 position, Quaternion rotation, NetworkReceivers receivers = NetworkReceivers.All, Action callback = null ) : void

Instantiate an object on the network from the resources folder

IsConnected ( BeardedManStudios.Network.NetWorker socket ) : bool

Determine if a NetWorker(Socket) reference is connected, (Dumbly returns socket.Connected)

IsConnected ( ushort port ) : bool

Determine if a NetWorker(Socket) is connected on a given port

LanDiscovery ( ushort port, int listenWaitTime = 10000, TransportationProtocolType protocol = TransportationProtocolType.UDP, bool winRT = false ) : IPEndPoint
LanDiscovery ( ushort port, int listenWaitTime = 10000, TransportationProtocolType protocol = TransportationProtocolType.UDP, bool winRT = false ) : IPEndPointWinRT

Finds the first host on the network on the specified port number in the local area network and makes a connection to it

NetworkingReset ( ) : void

To reset the network by clearing the sockets and disconnecting them if possible

Ping ( HostInfo host, ushort pingFromPort = 35791 ) : void

Ping a particular host to get its response time in milliseconds

RunInstantiateCallback ( int index, SimpleNetworkedMonoBehavior spawn ) : bool
SetBareMetal ( bool isBareMetal ) : void

Tell the system if we are currently running it as Bare Metal or not - Mainly internal

SetMyMessageGroup ( BeardedManStudios.Network.NetWorker socket, ushort groupId ) : void

This will set the message group for the specified socket connection

SetPrimarySocket ( BeardedManStudios.Network.NetWorker netWorker ) : void

Used to assign the Networking.PrimarySocket object to the specified NetWorker

Write ( BeardedManStudios.Network.NetWorker socket, NetworkingPlayer player, NetworkingStream stream ) : void

Writes a NetworkingStream to a particular NetWorker directly to a player (if the port is a server)

Write ( ushort port, NetworkingPlayer player, NetworkingStream stream ) : void

Writes a NetworkingStream to a particular NetWorker that is running on a particular port directly to a player (if the port is a server)

WriteCustom ( uint id, BeardedManStudios.Network.NetWorker netWorker, BMSByte data, NetworkingPlayer target, bool reliableUDP = false ) : void

TODO

WriteCustom ( uint id, BeardedManStudios.Network.NetWorker netWorker, BMSByte data, bool reliableUDP = false, NetworkReceivers recievers = NetworkReceivers.All ) : void

This allows you to write custom data across the network and is useful for serializing entire classes if needed

WriteCustom ( uint id, ushort port, BMSByte data, NetworkReceivers recievers = NetworkReceivers.All ) : void

This allows you to write custom data across the network and is useful for serializing entire classes if needed

WriteRaw ( BeardedManStudios.Network.NetWorker netWorker, BMSByte data, string uniqueId, bool reliable ) : void

Write a custom raw byte message with a 1 byte header across the network

WriteRaw ( BeardedManStudios.Network.NetWorker netWorker, NetworkingPlayer targetPlayer, BMSByte data, string uniqueId, bool reliable = false ) : void

Allows the server to send a raw message to a particular player

WriteTCP ( BeardedManStudios.Network.NetWorker socket, NetworkingStream stream ) : void

Write to the TCP given a NetWorker(Socket) with a stream of data

WriteTCP ( ushort port, NetworkingStream stream ) : void

Write to the TCP given a NetWorker(Socket) with a stream of data

WriteUDP ( BeardedManStudios.Network.NetWorker socket, string identifier, NetworkingStream stream, bool reliable = false ) : void

Writes a NetworkingStream to a particular NetWorker

WriteUDP ( ushort port, string identifier, NetworkingStream stream, bool reliable = false ) : void

Writes a NetworkingStream to a particular NetWorker that is running on a particular port

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

Метод Описание
CallInstantiate ( string obj, NetworkReceivers receivers, Action callback = null ) : void
CallInstantiate ( string obj, Vector3 position, Quaternion rotation, NetworkReceivers receivers, Action callback = null ) : void
ThreadPing ( object hostObj ) : void
ValidateNetworkedObject ( string name, SimpleNetworkedMonoBehavior &netBehavior ) : bool
WriteUDP ( string ip, ushort port, string updateidentifier, NetworkingStream stream, bool reliable = false ) : void

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

ChangeClientScene() публичный статический Метод

Tells the client to change their scene to the given scene. This is often called after the server has changed to that scene to ensure that the server will always load up the scene before the client does
public static ChangeClientScene ( BeardedManStudios.Network.NetWorker netWorker, NetworkingPlayer targetPlayer, string sceneName ) : void
netWorker BeardedManStudios.Network.NetWorker The current that will be sending the message
targetPlayer NetworkingPlayer The particular player that will be receiving this message
sceneName string The name of the scene in which the client should load
Результат void

ChangeClientScene() публичный статический Метод

Tells the client to change their scene to the given scene. This is often called after the server has changed to that scene to ensure that the server will always load up the scene before the client does
public static ChangeClientScene ( BeardedManStudios.Network.NetWorker netWorker, string sceneName ) : void
netWorker BeardedManStudios.Network.NetWorker
sceneName string The name of the scene in which the client should load
Результат void

ChangeClientScene() публичный статический Метод

Tells the client to change their scene to the given scene. This is often called after the server has changed to that scene to ensure that the server will always load up the scene before the client does
public static ChangeClientScene ( ushort port, NetworkingPlayer targetPlayer, string sceneName ) : void
port ushort The port of the that is to send the message
targetPlayer NetworkingPlayer The particular player that will be receiving this message
sceneName string The name of the scene in which the client should load
Результат void

ChangeClientScene() публичный статический Метод

Tells the client to change their scene to the given scene. This is often called after the server has changed to that scene to ensure that the server will always load up the scene before the client does
public static ChangeClientScene ( ushort port, string sceneName ) : void
port ushort The port of the that is to send the message
sceneName string The name of the scene in which the client should load
Результат void

ClientReady() публичный статический Метод

public static ClientReady ( BeardedManStudios.Network.NetWorker socket ) : void
socket BeardedManStudios.Network.NetWorker
Результат void

Connect() публичный статический Метод

Create and connect a client to the specified server ip and port
public static Connect ( string ip, ushort port, TransportationProtocolType comType, bool winRT = false, bool useNat = false, bool standAlone = false ) : BeardedManStudios.Network.NetWorker
ip string The host (usually ip address or domain name) to connect to
port ushort The port for the particular server that this connection is attempting
comType TransportationProtocolType The transportation protocol type that is to be used
winRT bool If this is Windows Phone or Windows Store, this should be true, otherwise default to false
useNat bool
standAlone bool
Результат BeardedManStudios.Network.NetWorker

Destroy() публичный статический Метод

Destroy a simple networked object
public static Destroy ( SimpleNetworkedMonoBehavior netBehavior ) : void
netBehavior SimpleNetworkedMonoBehavior Networked behavior to destroy
Результат void

Disconnect() публичный статический Метод

Disconnects all sockets and clients for this machine running under this system and removes them all from the lookup (calls Networking.NetworkingReset
public static Disconnect ( ) : void
Результат void

Disconnect() публичный статический Метод

Disconnect the specified NetWorker (socket) and remove it from the Networking.Sockets lookup
public static Disconnect ( BeardedManStudios.Network.NetWorker socket ) : void
socket BeardedManStudios.Network.NetWorker The socket to be shut down
Результат void

Disconnect() публичный статический Метод

Disconnect a player on a given NetWorker(Socket)
Thrown when the on the specified port is not a server
public static Disconnect ( BeardedManStudios.Network.NetWorker socket, NetworkingPlayer player ) : void
socket BeardedManStudios.Network.NetWorker NetWorker(Socket) to be disconnected from
player NetworkingPlayer The player reference to disconnect
Результат void

Disconnect() публичный статический Метод

Disconnects (on this machine) either a client or a server on the specified port
public static Disconnect ( ushort port ) : void
port ushort Port of the local server/client to be disconnected from
Результат void

Disconnect() публичный статический Метод

Disconnects a player on a given port
Thrown when there is not a on the supplied port Thrown when the on the specified port is not a server
public static Disconnect ( ushort port, NetworkingPlayer player ) : void
port ushort Port to disconnect from
player NetworkingPlayer Player to disconnect
Результат void

DynamicCommand() публичный статический Метод

public static DynamicCommand ( BeardedManStudios.Network.NetWorker socket, string command, bool relayOnServer = true, bool reliable = true ) : void
socket BeardedManStudios.Network.NetWorker
command string
relayOnServer bool
reliable bool
Результат void

GetLocalIPAddress() публичный статический Метод

Get the local Ip address
public static GetLocalIPAddress ( ) : string
Результат string

Host() публичный статический Метод

Will setup a new server on this machine
public static Host ( ushort port, TransportationProtocolType comType, int maxConnections, bool winRT = false, string overrideIP = null, bool allowWebplayerConnection = false, bool relayToAll = true, bool useNat = false, BeardedManStudios.Network.NetWorker errorCallback = null ) : BeardedManStudios.Network.NetWorker
port ushort This is the port you want to bind the server to
comType TransportationProtocolType The particular transportation protocol you wish to be used for this server
maxConnections int The maximum connections (players) allowed on the server at one point in time
winRT bool If this is Windows Phone or Windows Store, this should be true, otherwise default to false
overrideIP string
allowWebplayerConnection bool Allow web player connections to server
relayToAll bool Used to determine if messages should be relayed to client (normally true) - Mainly internal
useNat bool
errorCallback BeardedManStudios.Network.NetWorker
Результат BeardedManStudios.Network.NetWorker

InitializeFirewallCheck() публичный статический Метод

This will force a firewall request by the users machine to allow for network communications with this particular application
public static InitializeFirewallCheck ( ushort port ) : void
port ushort Port to be allowed
Результат void

Instantiate() публичный статический Метод

Instantiate an object on the network
public static Instantiate ( GameObject obj, NetworkReceivers receivers = NetworkReceivers.All, Action callback = null ) : void
obj UnityEngine.GameObject Object to be instantiated by object name
receivers NetworkReceivers Recipients will receive this instantiate call (Default: All)
callback Action
Результат void

Instantiate() публичный статический Метод

Instantiate an object on the network
public static Instantiate ( GameObject obj, Vector3 position, Quaternion rotation, NetworkReceivers receivers = NetworkReceivers.All, Action callback = null ) : void
obj UnityEngine.GameObject Object to be instantiated by object name
position Vector3 Position of instantiated object
rotation UnityEngine.Quaternion Rotation of instantiated object
receivers NetworkReceivers Recipients will receive this instantiate call (Default: All)
callback Action
Результат void

Instantiate() публичный статический Метод

Instantiate an object on the network
public static Instantiate ( string obj, NetworkReceivers receivers, Action callback = null ) : void
obj string Object to be instantiated by object name
receivers NetworkReceivers Recipients will receive this instantiate call
callback Action
Результат void

Instantiate() публичный статический Метод

Instantiate an object on the network
public static Instantiate ( string obj, Vector3 position, Quaternion rotation, NetworkReceivers receivers, Action callback = null ) : void
obj string Object to be instantiated by object name
position Vector3 Position of instantiated object
rotation UnityEngine.Quaternion Rotation of instantiated object
receivers NetworkReceivers Recipients will receive this instantiate call
callback Action
Результат void

InstantiateFromResources() публичный статический Метод

Instantiate an object on the network from the resources folder
public static InstantiateFromResources ( string resourcePath, NetworkReceivers receivers = NetworkReceivers.All, Action callback = null ) : void
resourcePath string Location of the resource
receivers NetworkReceivers Recipients will receive this instantiate call (Default: All)
callback Action
Результат void

InstantiateFromResources() публичный статический Метод

Instantiate an object on the network from the resources folder
public static InstantiateFromResources ( string resourcePath, Vector3 position, Quaternion rotation, NetworkReceivers receivers = NetworkReceivers.All, Action callback = null ) : void
resourcePath string Location of the resource
position Vector3 Position of instantiated object
rotation UnityEngine.Quaternion Rotation of instantiated object
receivers NetworkReceivers Recipients will receive this instantiate call (Default: All)
callback Action
Результат void

IsConnected() публичный статический Метод

Determine if a NetWorker(Socket) reference is connected, (Dumbly returns socket.Connected)
public static IsConnected ( BeardedManStudios.Network.NetWorker socket ) : bool
socket BeardedManStudios.Network.NetWorker NetWorker(Socket) to be checked
Результат bool

IsConnected() публичный статический Метод

Determine if a NetWorker(Socket) is connected on a given port
public static IsConnected ( ushort port ) : bool
port ushort The port number that is to be checked for a connection create by this system
Результат bool

LanDiscovery() публичный статический Метод

public static LanDiscovery ( ushort port, int listenWaitTime = 10000, TransportationProtocolType protocol = TransportationProtocolType.UDP, bool winRT = false ) : IPEndPoint
port ushort
listenWaitTime int
protocol TransportationProtocolType
winRT bool
Результат System.Net.IPEndPoint

LanDiscovery() публичный статический Метод

Finds the first host on the network on the specified port number in the local area network and makes a connection to it
public static LanDiscovery ( ushort port, int listenWaitTime = 10000, TransportationProtocolType protocol = TransportationProtocolType.UDP, bool winRT = false ) : IPEndPointWinRT
port ushort The port to connect to
listenWaitTime int The time in milliseconds to wait for a discovery
protocol TransportationProtocolType The protocol type for the server
winRT bool If this is Windows Phone or Windows Store, this should be true, otherwise default to false
Результат IPEndPointWinRT

NetworkingReset() публичный статический Метод

To reset the network by clearing the sockets and disconnecting them if possible
public static NetworkingReset ( ) : void
Результат void

Ping() публичный статический Метод

Ping a particular host to get its response time in milliseconds
public static Ping ( HostInfo host, ushort pingFromPort = 35791 ) : void
host HostInfo The host object to ping
pingFromPort ushort
Результат void

RunInstantiateCallback() публичный статический Метод

public static RunInstantiateCallback ( int index, SimpleNetworkedMonoBehavior spawn ) : bool
index int
spawn SimpleNetworkedMonoBehavior
Результат bool

SetBareMetal() публичный статический Метод

Tell the system if we are currently running it as Bare Metal or not - Mainly internal
public static SetBareMetal ( bool isBareMetal ) : void
isBareMetal bool If this is a Bare Metal instance
Результат void

SetMyMessageGroup() публичный статический Метод

This will set the message group for the specified socket connection
public static SetMyMessageGroup ( BeardedManStudios.Network.NetWorker socket, ushort groupId ) : void
socket BeardedManStudios.Network.NetWorker The NetWorker to assign the message group for
groupId ushort The unique identifier for the message group
Результат void

SetPrimarySocket() публичный статический Метод

Used to assign the Networking.PrimarySocket object to the specified NetWorker
public static SetPrimarySocket ( BeardedManStudios.Network.NetWorker netWorker ) : void
netWorker BeardedManStudios.Network.NetWorker The NetWorker that will be the primary socket
Результат void

Write() публичный статический Метод

Writes a NetworkingStream to a particular NetWorker directly to a player (if the port is a server)
Thrown when there is not a on the supplied port Thrown when the on the specified port is not a server
public static Write ( BeardedManStudios.Network.NetWorker socket, NetworkingPlayer player, NetworkingStream stream ) : void
socket BeardedManStudios.Network.NetWorker NetWorker(Socket) to write with
player NetworkingPlayer Player to be written to server
stream NetworkingStream The stream of data to be written
Результат void

Write() публичный статический Метод

Writes a NetworkingStream to a particular NetWorker that is running on a particular port directly to a player (if the port is a server)
Thrown when there is not a on the supplied port Thrown when the on the specified port is not a server
public static Write ( ushort port, NetworkingPlayer player, NetworkingStream stream ) : void
port ushort The port that the is listening on
player NetworkingPlayer The player that this server will be writing this message to
stream NetworkingStream The data stream that is to be written to the player
Результат void

WriteCustom() публичный статический Метод

TODO
public static WriteCustom ( uint id, BeardedManStudios.Network.NetWorker netWorker, BMSByte data, NetworkingPlayer target, bool reliableUDP = false ) : void
id uint Unique identifier to be used
netWorker BeardedManStudios.Network.NetWorker The NetWorker(Socket) to write with
data BMSByte Data to send over
target NetworkingPlayer
reliableUDP bool If this be a reliable UDP
Результат void

WriteCustom() публичный статический Метод

This allows you to write custom data across the network and is useful for serializing entire classes if needed
public static WriteCustom ( uint id, BeardedManStudios.Network.NetWorker netWorker, BMSByte data, bool reliableUDP = false, NetworkReceivers recievers = NetworkReceivers.All ) : void
id uint Unique identifier to be used
netWorker BeardedManStudios.Network.NetWorker The NetWorker(Socket) to write with
data BMSByte Data to send over
reliableUDP bool If this be a reliable UDP
recievers NetworkReceivers
Результат void

WriteCustom() публичный статический Метод

This allows you to write custom data across the network and is useful for serializing entire classes if needed
public static WriteCustom ( uint id, ushort port, BMSByte data, NetworkReceivers recievers = NetworkReceivers.All ) : void
id uint Unique identifier to be used
port ushort Port to be written to
data BMSByte Data to send over
recievers NetworkReceivers
Результат void

WriteRaw() публичный статический Метод

Write a custom raw byte message with a 1 byte header across the network
public static WriteRaw ( BeardedManStudios.Network.NetWorker netWorker, BMSByte data, string uniqueId, bool reliable ) : void
netWorker BeardedManStudios.Network.NetWorker
data BMSByte
uniqueId string
reliable bool
Результат void

WriteRaw() публичный статический Метод

Allows the server to send a raw message to a particular player
public static WriteRaw ( BeardedManStudios.Network.NetWorker netWorker, NetworkingPlayer targetPlayer, BMSByte data, string uniqueId, bool reliable = false ) : void
netWorker BeardedManStudios.Network.NetWorker
targetPlayer NetworkingPlayer
data BMSByte
uniqueId string
reliable bool
Результат void

WriteTCP() публичный статический Метод

Write to the TCP given a NetWorker(Socket) with a stream of data
public static WriteTCP ( BeardedManStudios.Network.NetWorker socket, NetworkingStream stream ) : void
socket BeardedManStudios.Network.NetWorker The NetWorker(Socket) to write with
stream NetworkingStream The stream of data to be written
Результат void

WriteTCP() публичный статический Метод

Write to the TCP given a NetWorker(Socket) with a stream of data
public static WriteTCP ( ushort port, NetworkingStream stream ) : void
port ushort Port of the given NetWorker(Socket)
stream NetworkingStream The stream of data to be written
Результат void

WriteUDP() публичный статический Метод

Writes a NetworkingStream to a particular NetWorker
public static WriteUDP ( BeardedManStudios.Network.NetWorker socket, string identifier, NetworkingStream stream, bool reliable = false ) : void
socket BeardedManStudios.Network.NetWorker NetWorker(Socket) to write with
identifier string Unique identifier to be used
stream NetworkingStream The stream of data to be written
reliable bool If this be a reliable UDP
Результат void

WriteUDP() публичный статический Метод

Writes a NetworkingStream to a particular NetWorker that is running on a particular port
public static WriteUDP ( ushort port, string identifier, NetworkingStream stream, bool reliable = false ) : void
port ushort Port of the given NetWorker(Socket)
identifier string Unique identifier to be used
stream NetworkingStream The stream of data to be written
reliable bool If this be a reliable UDP
Результат void

Описание свойств

RunActionsInFixedLoop публичное статическое свойство

public static bool RunActionsInFixedLoop
Результат bool