C# Class BeardedManStudios.Network.Networking

Datei anzeigen Open project: drakelinglabs/unityarmada Class Usage Examples

Public Properties

Property Type Description
RunActionsInFixedLoop bool

Public Methods

Method Description
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

Private Methods

Method Description
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

Method Details

ChangeClientScene() public static method

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

ChangeClientScene() public static method

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

ChangeClientScene() public static method

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

ChangeClientScene() public static method

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

ClientReady() public static method

public static ClientReady ( BeardedManStudios.Network.NetWorker socket ) : void
socket BeardedManStudios.Network.NetWorker
return void

Connect() public static method

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
return BeardedManStudios.Network.NetWorker

Destroy() public static method

Destroy a simple networked object
public static Destroy ( SimpleNetworkedMonoBehavior netBehavior ) : void
netBehavior SimpleNetworkedMonoBehavior Networked behavior to destroy
return void

Disconnect() public static method

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

Disconnect() public static method

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

Disconnect() public static method

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

Disconnect() public static method

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

Disconnect() public static method

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

DynamicCommand() public static method

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

GetLocalIPAddress() public static method

Get the local Ip address
public static GetLocalIPAddress ( ) : string
return string

Host() public static method

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
return BeardedManStudios.Network.NetWorker

InitializeFirewallCheck() public static method

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

Instantiate() public static method

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

Instantiate() public static method

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

Instantiate() public static method

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

Instantiate() public static method

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

InstantiateFromResources() public static method

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

InstantiateFromResources() public static method

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

IsConnected() public static method

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

IsConnected() public static method

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

LanDiscovery() public static method

public static LanDiscovery ( ushort port, int listenWaitTime = 10000, TransportationProtocolType protocol = TransportationProtocolType.UDP, bool winRT = false ) : IPEndPoint
port ushort
listenWaitTime int
protocol TransportationProtocolType
winRT bool
return System.Net.IPEndPoint

LanDiscovery() public static method

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

NetworkingReset() public static method

To reset the network by clearing the sockets and disconnecting them if possible
public static NetworkingReset ( ) : void
return void

Ping() public static method

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

RunInstantiateCallback() public static method

public static RunInstantiateCallback ( int index, SimpleNetworkedMonoBehavior spawn ) : bool
index int
spawn SimpleNetworkedMonoBehavior
return bool

SetBareMetal() public static method

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

SetMyMessageGroup() public static method

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

SetPrimarySocket() public static method

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

Write() public static method

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

Write() public static method

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

WriteCustom() public static method

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

WriteCustom() public static method

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

WriteCustom() public static method

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

WriteRaw() public static method

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

WriteRaw() public static method

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

WriteTCP() public static method

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

WriteTCP() public static method

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

WriteUDP() public static method

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

WriteUDP() public static method

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

Property Details

RunActionsInFixedLoop public_oe static_oe property

public static bool RunActionsInFixedLoop
return bool