Exemple #1
0
 /// <summary>
 /// Event handler for the receiver side.
 /// </summary>
 /// <param name="src">receiver mCall object</param>
 /// <param name="args">event specific arguments</param>
 private void Receiver_CallEvent(object src, CallEventArgs args)
 {
     if (args.Type == CallEventType.ConfigurationComplete)
     {
         //STEP3: Connect to the previously set signaling server
         //and try to listen for incoming calls on the set address.
         Debug.Log("receiver configuration done. Listening on address " + address);
         receiver.Listen(address);
     }
     else if (args.Type == CallEventType.WaitForIncomingCall)
     {
         //STEP4A: Our address is registered with the server now
         //we wait for the sender to connect
         Debug.Log("receiver is ready to accept incoming calls");
         //setup the sender to connect
         SenderSetup();
     }
     else if (args.Type == CallEventType.ListeningFailed)
     {
         //STEP4B: Alternatively, we failed to listen.
         //e.g. due to no internet / server down / address in use
         //currently no specific error information are available.
         Debug.LogError("receiver failed to listen to the address");
     }
     else if (args.Type == CallEventType.CallAccepted)
     {
         //STEP7:
         //The sender connected successfully and a direct connection was
         //created.
         Debug.Log("receiver CallAccepted");
     }
 }
Exemple #2
0
        private void Call()
        {
            string address = Application.productName + "_SimpleCall";

            if (_Sender)
            {
                //STEP4: Sender calls (outgoing connection)
                mCall.Call(address);
            }
            else
            {
                //STEP4: Receiver listens (waiting for incoming connection)
                mCall.Listen(address);
            }
            mState = SimpleCallState.Calling;
        }
Exemple #3
0
        private void OnCallEvent(object src, CallEventArgs args)
        {
            ICall call  = src as ICall;
            int   index = Array.IndexOf(calls, call);

            if (args.Type == CallEventType.ConfigurationComplete)
            {
                Debug.Log(index + ": configuration done. Listening on address " + address);
                //ALL connections will call listen. The current conference call version
                //will connect all users that listen to the same address
                //resulting in an N to N / full mesh topology
                call.Listen(address);
            }
            else if (args.Type == CallEventType.CallAccepted)
            {
                Debug.Log(index + ": CallAccepted");
            }
            else if (args.Type == CallEventType.ConfigurationFailed || args.Type == CallEventType.ListeningFailed)
            {
                Debug.LogError(index + ": failed");
            }
        }
Exemple #4
0
 private void Echo_CallEvent(object src, CallEventArgs args)
 {
     if (args.Type == CallEventType.ConfigurationComplete)
     {
         string address = BenchmarkConfig.Address;
         Debug.Log("echo configuration done. Listening on address " + address);
         echo.Listen(address);
     }
     else if (args.Type == CallEventType.WaitForIncomingCall)
     {
         Debug.Log("echo is ready to accept incoming calls");
         mActive = true;
     }
     else if (args.Type == CallEventType.ListeningFailed)
     {
         mActive = false;
         Debug.LogError("echo failed to listen to the address");
         Restart();
     }
     else if (args.Type == CallEventType.CallAccepted)
     {
         Debug.Log("echo CallAccepted");
         CallAcceptedEventArgs ev = args as CallAcceptedEventArgs;
         mToSender  = ev.ConnectionId;
         mConnected = true;
     }
     else if (args.Type == CallEventType.DataMessage)
     {
         var    margs = args as DataMessageEventArgs;
         byte[] data  = margs.Content;
         OnMessageReceived(data);
     }
     else if (args.Type == CallEventType.CallEnded)
     {
         mActive    = false;
         mConnected = false;
         Restart();
     }
 }
 /// <summary>
 /// Join button pressed. Tries to join a room.
 /// </summary>
 public void JoinButtonPressed()
 {
     Setup();
     EnsureLength();
     mCall.Listen(uRoomName.text);
 }
Exemple #6
0
    private void Connect()
    {
        DebugLog.AddEntry("connecting...");

        // create network config
        if (networkConfig == null)
        {
            networkConfig = CreateNetworkConfig(account);
        }

        // setup caller
        caller = UnityCallFactory.Instance.Create(networkConfig);
        if (caller == null)
        {
            Debug.Log("Failed to create caller");
            return;
        }

        caller.LocalFrameEvents = true;
        caller.CallEvent       += HandleCallEvent;

        // setup media config
        if (mediaConfig == null)
        {
            mediaConfig = CreateMediaConfig();

            // prefer the external video device
            if (UnityCallFactory.Instance.CanSelectVideoDevice())
            {
                string[] videoDevices = UnityCallFactory.Instance.GetVideoDevices();

                // show all video device names
                for (int i = 0; i < videoDevices.Length; i++)
                {
                    var name = videoDevices[i];
                    DebugLog.AddEntry("video device #" + i + ": " + name);
                }

                var preferredDevice = PlayerPrefs.GetInt(PREFS.VIDEO_DEVICE);
                if (preferredDevice < videoDevices.Length)
                {
                    mediaConfig.VideoDeviceName = videoDevices[preferredDevice];
                }
                else
                {
                    // use defualt device if the preferred device is out of range
                    mediaConfig.VideoDeviceName = videoDevices[0];
                }
            }
            else
            {
                mediaConfig.VideoDeviceName = UnityCallFactory.Instance.GetDefaultVideoDevice();
            }
            DebugLog.AddEntry("Using video device: " + mediaConfig.VideoDeviceName);
        }

        caller.Configure(mediaConfig);

        // start listening...
        if (Globals.role == Role.Therapist)
        {
            DebugLog.AddEntry("server listening for connections on " + account.address + "...");
            SetStatusMessageText("Listening for connections on " + account.address + "...");
            caller.Listen(account.address);
        }
        else
        {
            DebugLog.AddEntry("client connecting to " + account.address + "...");
            SetStatusMessageText("Connecting to " + account.address + "...");
            caller.Call(account.address);
        }
    }