WebRTC Network  0.96
Classes | Public Member Functions | Protected Member Functions | Properties | List of all members
Byn.Net.LocalNetwork Class Reference

LocalNetwork. Simulate the IBasicNetwork locally in a single applicaiton. More...

Inheritance diagram for Byn.Net.LocalNetwork:
Byn.Net.IBasicNetwork Byn.Net.INetwork

Public Member Functions

void StartServer (string serverAddress=null)
 Starts a server + asking for it to have a certain address. The use of the address is not guaranteed. If the address is in use the underlaying system will return ServerConnectionFailed. (This can also be triggered if anything else fails in the process) More...
 
void StopServer ()
 Stops incoming connections. This usually doesn't close existing connections thus can be used to enforce a certain amount of maximum allowed connections. More...
 
ConnectionId Connect (string address)
 Connects to a given address or room name. More...
 
void Shutdown ()
 Disconnects all connection and shuts down the server if started. Dequeue will still return the confirmation messages such as Disconnected event for each connection. More...
 
void SendData (ConnectionId userId, byte[] data, int offset, int length, bool reliable)
 Sends the content if a byte array to the given connection. More...
 
void Update ()
 Call this every frame if you intend to read incoming messages using Dequeue. This will make sure all data is read received by the network. More...
 
bool Dequeue (out NetworkEvent evt)
 This will return the incoming network events. Call this method and handle the incoming events until it returns false. More...
 
bool Peek (out NetworkEvent evt)
 Will return the first event in the queue without removing it. More...
 
void Flush ()
 Sends buffered data. More...
 
void Disconnect (ConnectionId id)
 Disconnects the given connection More...
 
void Dispose ()
 

Protected Member Functions

virtual void Dispose (bool disposing)
 

Properties

IList< ConnectionIdConnections [get]
 
bool IsServer [get]
 

Detailed Description

LocalNetwork. Simulate the IBasicNetwork locally in a single applicaiton.

Member Function Documentation

ConnectionId Byn.Net.LocalNetwork.Connect ( string  address)

Connects to a given address or room name.

This call will result in one of those 2 events in response:

  • NewConnection if the connection was established
  • ConnectionFailed if the connection failed.
Parameters
addressA string that identifies the target.
Returns
Returns the Connection id the established connection will have (only supported by WebRtcNetwork).

Implements Byn.Net.IBasicNetwork.

bool Byn.Net.LocalNetwork.Dequeue ( out NetworkEvent  evt)

This will return the incoming network events. Call this method and handle the incoming events until it returns false.

Parameters
evt
Returns
Returns true if the parameter evt contains a new event. False if there are no events to process left.

Implements Byn.Net.INetwork.

void Byn.Net.LocalNetwork.Disconnect ( ConnectionId  id)

Disconnects the given connection

Parameters
idId of the connection to disconnect.

Implements Byn.Net.INetwork.

void Byn.Net.LocalNetwork.Flush ( )

Sends buffered data.

Implements Byn.Net.INetwork.

bool Byn.Net.LocalNetwork.Peek ( out NetworkEvent  evt)

Will return the first event in the queue without removing it.

Parameters
evt
Returns

Implements Byn.Net.INetwork.

void Byn.Net.LocalNetwork.SendData ( ConnectionId  id,
byte[]  data,
int  offset,
int  length,
bool  reliable 
)

Sends the content if a byte array to the given connection.

Parameters
idThe id of the recipient
dataByte array containing the data to send
offsetThe index in data where the network should start to send
lengthLength in bytes you want to send
reliableTrue to send a reliable message(TCP style) and false to send unreliable (UDP style)

Implements Byn.Net.INetwork.

void Byn.Net.LocalNetwork.Shutdown ( )

Disconnects all connection and shuts down the server if started. Dequeue will still return the confirmation messages such as Disconnected event for each connection.

Implements Byn.Net.INetwork.

void Byn.Net.LocalNetwork.StartServer ( string  address = null)

Starts a server + asking for it to have a certain address. The use of the address is not guaranteed. If the address is in use the underlaying system will return ServerConnectionFailed. (This can also be triggered if anything else fails in the process)

Parameters
address

Implements Byn.Net.IBasicNetwork.

void Byn.Net.LocalNetwork.StopServer ( )

Stops incoming connections. This usually doesn't close existing connections thus can be used to enforce a certain amount of maximum allowed connections.

Implements Byn.Net.IBasicNetwork.

void Byn.Net.LocalNetwork.Update ( )

Call this every frame if you intend to read incoming messages using Dequeue. This will make sure all data is read received by the network.

Implements Byn.Net.INetwork.


The documentation for this class was generated from the following file: