WebRTC Video Chat 1.1.4
Loading...
Searching...
No Matches
Byn.Awrtc.NetworkEvent Struct Reference

Contains information about events received by the network. More...

Public Member Functions

byte[] GetDataAsByteArray ()
 Returns the a copy of the message data as a new byte array with the exact size of the content instead of the buffer.
 
 NetworkEvent (NetEventType t)
 Creates a new network event of a certain type setting connection id to invalid and data to null.
 
 NetworkEvent (NetEventType t, ConnectionId conId)
 Events without data connected.
 
 NetworkEvent (NetEventType t, ConnectionId conId, MessageDataBuffer dt)
 Creates a network event with the given content Internal only. Do not use.
 
 NetworkEvent (NetEventType t, ConnectionId conId, object dt)
 Old constructor.
 
 NetworkEvent (NetEventType t, ConnectionId conId, string address)
 ServerInit events with address info.
 
 NetworkEvent (NetEventType t, ConnectionId conId, ErrorInfo errorInfo)
 Network event with ErrorInfo attached. ErrorInfo can't be serialized yet!
 
override string ToString ()
 Converts the event to string. Use for debugging only.
 
void AttachError (ErrorInfo error)
 Internal use only. Used to attach additional error information.
 

Static Public Member Functions

static bool IsMetaEvent (byte[] arr)
 Checks if this is a special event that isn't suppose to be processed as NetworkEvent. Special events are null, empty byte[0] and any values starting with a byte equal or above NetEventType.ReservedStart;.
 
static NetworkEvent FromByteArray (byte[] arr)
 Reverse of ToByteArray.
 
static byte[] ToByteArray (NetworkEvent evt)
 Mainly used by WebsocketNetwork. It serializes network events into a byte array to allow to process the events on a different system than where it actually occurred.
 

Properties

NetEventType Type [get]
 Returns the type of the message.
 
ConnectionId ConnectionId [get]
 Returns the related connection id or ConnecitonId.Invalid if there is none.
 
object RawData [get]
 Returns an object belonging to the event. This can be a MessageDataBuffer containing a byte array or a string or an errorinfo object.
 
MessageDataBuffer MessageData [get]
 Returns the content of the messages if the event type is UnreliableMessageReceived or ReliableMessageReceived.
 
string Info [get]
 Contains additional information or null Only used so far for NetEventType.ServerInitialized to return the servers address information.
 
ErrorInfo ErrorInfo [get]
 Returns an error info object if one is connected.
 

Detailed Description

Contains information about events received by the network.

The type of the network event decides the content it can contain.

Most important are:

UnreliableMessageReceived / ReliableMessageReceived: A new message was received. The property MessageData will return a buffer + byte array containing the data received.

ServerInitialized: A call to StartServer was successful. The Info property will return the address the server can be accessed by.

Constructor & Destructor Documentation

◆ NetworkEvent() [1/6]

Byn.Awrtc.NetworkEvent.NetworkEvent ( NetEventType t)

Creates a new network event of a certain type setting connection id to invalid and data to null.

Internal only. Do not use.

Parameters
tThe type of this event

◆ NetworkEvent() [2/6]

Byn.Awrtc.NetworkEvent.NetworkEvent ( NetEventType t,
ConnectionId conId )

Events without data connected.

Parameters
t
conId

◆ NetworkEvent() [3/6]

Byn.Awrtc.NetworkEvent.NetworkEvent ( NetEventType t,
ConnectionId conId,
MessageDataBuffer dt )

Creates a network event with the given content Internal only. Do not use.

Parameters
tType name
conIdConnectionId the event is from / relates to
dtMessageDataBuffer (should be ByteArrayBuffer)

◆ NetworkEvent() [4/6]

Byn.Awrtc.NetworkEvent.NetworkEvent ( NetEventType t,
ConnectionId conId,
object dt )

Old constructor.

Parameters
t
conId
dt

◆ NetworkEvent() [5/6]

Byn.Awrtc.NetworkEvent.NetworkEvent ( NetEventType t,
ConnectionId conId,
string address )

ServerInit events with address info.

Parameters
t
conId
address

◆ NetworkEvent() [6/6]

Byn.Awrtc.NetworkEvent.NetworkEvent ( NetEventType t,
ConnectionId conId,
ErrorInfo errorInfo )

Network event with ErrorInfo attached. ErrorInfo can't be serialized yet!

Parameters
t
conId
errorInfo

Member Function Documentation

◆ AttachError()

void Byn.Awrtc.NetworkEvent.AttachError ( ErrorInfo error)

Internal use only. Used to attach additional error information.

Parameters
error

◆ FromByteArray()

static NetworkEvent Byn.Awrtc.NetworkEvent.FromByteArray ( byte[] arr)
static

Reverse of ToByteArray.

Parameters
arr
Returns

◆ GetDataAsByteArray()

byte[] Byn.Awrtc.NetworkEvent.GetDataAsByteArray ( )

Returns the a copy of the message data as a new byte array with the exact size of the content instead of the buffer.

Returns
Copy of the message data or null if no message data available

◆ IsMetaEvent()

static bool Byn.Awrtc.NetworkEvent.IsMetaEvent ( byte[] arr)
static

Checks if this is a special event that isn't suppose to be processed as NetworkEvent. Special events are null, empty byte[0] and any values starting with a byte equal or above NetEventType.ReservedStart;.

Parameters
arr
Returns

true - means the message needs special handling and can't be passed to FromByteArray.

false - means the message can be a NetworkEvent but could still be invalid.

◆ ToByteArray()

static byte[] Byn.Awrtc.NetworkEvent.ToByteArray ( NetworkEvent evt)
static

Mainly used by WebsocketNetwork. It serializes network events into a byte array to allow to process the events on a different system than where it actually occurred.

e.g. WebsocketNetwork uses a server that will receive incoming connects and then serializes that event into a byte array and send it to the client which holds the address of the incoming connection to process the event

NOTE: This method is not optimized and shouldn't be used with a lot of data!

Parameters
evtNetwork event to be serialized
Returns
Newly created byte array representing the network event

◆ ToString()

override string Byn.Awrtc.NetworkEvent.ToString ( )

Converts the event to string. Use for debugging only.

Returns
A string representation of the network event.

Property Documentation

◆ MessageData

MessageDataBuffer Byn.Awrtc.NetworkEvent.MessageData
get

Returns the content of the messages if the event type is UnreliableMessageReceived or ReliableMessageReceived.

null for all other message types.


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