Uses an underlaying java script library to give network access in browsers. Use WebRtcNetwork.IsAvailable() first to check if it can run. If the java script part of the library is included + the browser supports WebRtc it should return true. If the java script part of the library is not included you can inject it at runtime by using WebRtcNetwork.InjectJsCode(). It is recommecend to include the js files though. To allow incomming connections use StartServer() or StartServer("my room name") To connect oothers use Connect("room name"); To send messages use SendData. You will need to handle incomming events by polling the Dequeue method.
Inheritance: IBasicNetwork
Example #1
0
 private IEnumerator CoroutineCleanup()
 {
     yield return new WaitForSeconds(5);
     mServer.Dispose();
     mClient.Dispose();
     mServer = null;
     mClient = null;
     if (mState == State.TestSuccessful)
     {
         Debug.Log("------------All tests successful!-------------");
     }
 }
Example #2
0
    private void StartTest()
    {
        if (WebRtcNetwork.IsAvailable() == false)
        {
            Debug.LogWarning("WebRtcNetwork not available. Please run it in WebGL to test WebRtcNetwork!");
        }
        else
        {
            Debug.Log("WebRtcNetwork available. Starting test.");
            mServer = new WebRtcNetwork();
            mClient = new WebRtcNetwork();
            Debug.Log("Instance created");

            mState = State.ServerInit;
            Debug.Log("Start test " + mState);
            mServer.StartServer();
        }
    }