Method | Description | |
---|---|---|
Connect ( string name ) : |
Connects to the given name or address.
|
|
Dequeue ( |
Dequeues a new event
|
|
Disconnect ( |
Disconnects the given connection id.
|
|
Dispose ( ) : void |
Disposes the underlaying java script library. If you have long running systems that don't reuse instances make sure you always call dispose as unity doesn't seem to call destructors reliably. You might fill up your java script memory with lots of unused instances.
|
|
Flush ( ) : void |
Flushes messages. Not needed in WebRtcNetwork but use it at the end of a frame if you want to be able to replace WebRtcNetwork with other implementations
|
|
InjectJsCode ( ) : void |
This injects the library using ExternalEval. Browsers seem to load some libraries asynchronly though. This means that directly after InjectJsCode some things aren't available yet. So starting a server/connecting won't work directly after this call yet. Add at least 1-2 seconds waiting time for the browser to download the libraries or better -> include everything needed into the websites header so this call isn't needed at all!
|
|
IsAvailable ( ) : bool |
Will return true if the environment supports the WebRTCNetwork plugin (needs to run in Chrome or Firefox + the javascript file needs to be loaded in the html page!) Keep in mind that it doesn't check if libraries needed for signaling channels are loaded! e.g. it returns true even though firebase or socket.io are missing. Make sure the webpage is setup properly including those in the header tag!
|
|
SendData ( |
Sends a byte array
|
|
Shutdown ( ) : void |
Shuts webrtc down. All connection will be disconnected + if the server is started it will be stopped. The instance itself isn't released yet! Use Dispose to destroy the network entirely.
|
|
StartServer ( ) : void |
Starts a server using a random number as address/name. Read the ServerInitialized events Info property to get the address name.
|
|
StartServer ( string name ) : void |
Allows to listen to incomming connections using a given name/address. This is in addition to the definition of the IBaseNetwork interface which is shared with other network systems enforcing the use of ip:port as address, thus can't allow custom addresses.
|
|
Update ( ) : void |
Needs to be called to read data from the unterlaying network and update this class. Use Dequeue to get the events it read.
|
|
WebRtcNetwork ( ) : System |
Creates a WebRtcNetwork using default values. This can be used for testing but as it uses an unreliable test server you should setup the WebRtcNetwork(config) for anything you want to release.
|
|
WebRtcNetwork ( string config ) : System |
Creats a new network by using a JSON configuration string. This is used to configure the server connection for the signaling channel and to define webrtc specific configurations such as stun server used to connect through firewalls. might look like this: string config = "{ \"Signaling\" : { \"name\" : \"FirebaseSignalingChan\", \"conf\" : \"https://incandescent-inferno-5269.firebaseio.com/webrtcnetwork0_9/\"}}"; or string config = "{ \"Signaling\" : { \"name\" : \"SocketIoSignalingChan\", \"conf\" : \"https://4science.azurewebsites.net:443\"},{\"iceServers\" : [ {\"url\":\"stun:stun.l.google.com:19302\"}]}}"; Make sure all json " signs are escaped. The JSON object will be parsed in java script and then given to the library. So their content is dependend on the underlaying library. Check out the webrtcnetwork.js to understand the details.
|
Method | Description | |
---|---|---|
Dispose ( bool disposing ) : void |
Method | Description | |
---|---|---|
DequeueInternal ( |
Retrieves an event from the js library, handles it internallay and then adds it to a queue for delivery to the user.
|
|
HandleEventInternally ( |
Handles events internally. Needed to change the internal states: Server flag and connection id list. Would be better to remove that in the future from the main library and treat it separately.
|
|
UnityWebRtcNetworkConnect ( int lIndex, string lRoom ) : int | ||
UnityWebRtcNetworkCreate ( string lConfiguration ) : int | ||
UnityWebRtcNetworkDequeue ( int lIndex, int lTypeIntArrayPtr, int lConidIntArrayPtr, byte lUint8ArrayDataPtr, int lUint8ArrayDataOffset, int lUint8ArrayDataLength, int lDataLenIntArray ) : bool | ||
UnityWebRtcNetworkDisconnect ( int lIndex, int lConnectionId ) : void | ||
UnityWebRtcNetworkIsAvailable ( ) : bool | ||
UnityWebRtcNetworkPeekEventDataLength ( int lIndex ) : int | ||
UnityWebRtcNetworkRelease ( int lIndex ) : void | ||
UnityWebRtcNetworkSendData ( int lIndex, int lConnectionId, byte lUint8ArrayDataPtr, int lUint8ArrayDataOffset, int lUint8ArrayDataLength, bool lReliable ) : void | ||
UnityWebRtcNetworkShutdown ( int lIndex ) : void | ||
UnityWebRtcNetworkStartServer ( int lIndex, string lRoom ) : void |
public Connect ( string name ) : |
||
name | string | The address identifying the server |
return |
public Dequeue ( |
||
evt | ||
return | bool |
public Disconnect ( |
||
id | Id to disconnect | |
return | void |
public SendData ( |
||
conId | Connection id the message should be delivered to. | |
data | byte | Content/Buffer that contains the content |
offset | int | Start index of the content in data |
length | int | Length of the content in data |
reliable | bool | True to use the ordered, reliable trainfer, false for unordered and unreliable |
return | void |
public StartServer ( string name ) : void | ||
name | string | Name/Address can be any kind of string. There might be restrictions though depending /// on the underlaying signaling channel. /// An invalid name will result in an InitFailed event being return in Dequeue. |
return | void |
public WebRtcNetwork ( string config ) : System | ||
config | string | |
return | System |