WebRTC Video Chat 1.1.4
Loading...
Searching...
No Matches
Byn.Awrtc.INetwork Interface Reference

Interface to a network that doesn't enforce storing any states. More...

Inheritance diagram for Byn.Awrtc.INetwork:
Byn.Awrtc.IBasicNetwork Byn.Awrtc.IWebRtcNetwork Byn.Awrtc.LocalNetwork Byn.Awrtc.IMediaNetwork

Public Member Functions

bool Dequeue (out NetworkEvent evt)
 This will return the incoming network events. Call this method and handle the incoming events until it returns false.
 
bool Peek (out NetworkEvent evt)
 Will return the first event in the queue without removing it.
 
void Flush ()
 Sends buffered data.
 
bool SendData (ConnectionId id, byte[] data, int offset, int length, bool reliable)
 Sends the content of a byte array to the given connection.
 
void Disconnect (ConnectionId id)
 Disconnects the given connection.
 
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.
 
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.
 

Detailed Description

Interface to a network that doesn't enforce storing any states.

Anything more is reusable between multiple different networks.

Member Function Documentation

◆ Dequeue()

bool Byn.Awrtc.INetwork.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.

Implemented in Byn.Awrtc.LocalNetwork.

◆ Disconnect()

void Byn.Awrtc.INetwork.Disconnect ( ConnectionId id)

Disconnects the given connection.

Parameters
idId of the connection to disconnect.

Implemented in Byn.Awrtc.LocalNetwork.

◆ Flush()

void Byn.Awrtc.INetwork.Flush ( )

Sends buffered data.

Implemented in Byn.Awrtc.LocalNetwork.

◆ Peek()

bool Byn.Awrtc.INetwork.Peek ( out NetworkEvent evt)

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

Parameters
evt
Returns

Implemented in Byn.Awrtc.LocalNetwork.

◆ SendData()

bool Byn.Awrtc.INetwork.SendData ( ConnectionId id,
byte[] data,
int offset,
int length,
bool reliable )

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

Make sure to check the result of this method. False indicates the data wasn't sent.

Calls to SendData will store the data in an internal buffer. Once the network is ready the data will be sent.

Pitfalls and additional information:

  • Sending data faster than the network can deliver will increase the buffered amount and thus increase the latency between the two peers.
  • the buffer is several MB but once full this method will return false and stop accepting data until the network could deliver more data
  • Keep package size under 16,000,000 bytes
  • For low latency keep the size and buffered data as low as possible
  • For high throughput keep the buffer size high (this class is not optimized for throughput though)
  • Use IWebRtcNetwork.GetBufferedAmount to check the buffer size
  • Add your own congestion control to better keep track on the data flow to ensure other devices can keep up with the amount of data sent.
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. Keep below 16,000,000 bytes
reliableTrue to send a reliable message(TCP style) and false to send unreliable (UDP style). Reliable messages are ordered and will be resent if lost during transmission. They can still be dropped if the internal buffer overflows (will return false). Unreliable messages are sent without a specific order and won't be resent if delivery fails even if this method returned true!
Returns
Returns false if:
  • The id is invalid (should never happen unless you have a bug in your code)
  • the the connection is disconnected (you will also get an event via Dequeue to handle it)
  • The internal buffer is full to buffer /returns>

Implemented in Byn.Awrtc.LocalNetwork.

◆ Shutdown()

void Byn.Awrtc.INetwork.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.

Implemented in Byn.Awrtc.LocalNetwork.

◆ Update()

void Byn.Awrtc.INetwork.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.

Implemented in Byn.Awrtc.LocalNetwork.


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