Beispiel #1
0
 public static void Register(ICall sender, int n)
 {
     for (int i = 1; i <= n; i++)
     {
         sender.Call();
     }
 }
Beispiel #2
0
 private void Sender_CallEvent(object src, CallEventArgs args)
 {
     if (args.Type == CallEventType.ConfigurationComplete)
     {
         Debug.Log("sender: configuration done. Listening on address " + BenchmarkConfig.Address);
         sender.Call(BenchmarkConfig.Address);
     }
     else if (args.Type == CallEventType.ConfigurationFailed)
     {
         Debug.LogError("sender: failed to access the audio device");
     }
     else if (args.Type == CallEventType.ConnectionFailed)
     {
         mIsActive = false;
         Debug.LogError("sender: failed to connect");
     }
     else if (args.Type == CallEventType.CallAccepted)
     {
         Debug.Log("sender CallAccepted");
         CallAcceptedEventArgs ev = args as CallAcceptedEventArgs;
         mToEcho    = ev.ConnectionId;
         mIsActive  = true;
         mStartTime = DateTime.Now;
     }
     else if (args.Type == CallEventType.CallEnded)
     {
         Debug.Log("sender: received CallEnded event");
         mIsActive = false;
     }
     else if (args.Type == CallEventType.DataMessage)
     {
         var margs = args as DataMessageEventArgs;
         OnMessageReceived(margs.Content);
     }
 }
Beispiel #3
0
 private void Sender_CallEvent(object src, CallEventArgs args)
 {
     if (args.Type == CallEventType.ConfigurationComplete)
     {
         //STEP6: we got access to media devices
         Debug.Log("sender configuration done. Listening on address " + address);
         sender.Call(address);
     }
     else if (args.Type == CallEventType.ConfigurationFailed)
     {
         //STEP6: user might have blocked access?
         Debug.LogError("sender failed to access the audio device");
     }
     else if (args.Type == CallEventType.ConnectionFailed)
     {
         //This can happen if the signaling connection failed or
         //if the direct connection failed e.g. due to firewall
         //See FAQ for more info how to find problems that cause this
         Debug.LogError("sender failed to connect");
     }
     else if (args.Type == CallEventType.CallAccepted)
     {
         //STEP7: Call Accepted
         Debug.Log("sender CallAccepted");
     }
     else if (args.Type == CallEventType.CallEnded)
     {
         //STEP8: CallEnded. Either network died or
         //one of the calls was destroyed/disposed
         Debug.Log("sender received CallEnded event");
     }
 }
Beispiel #4
0
        public static object CallWithThisAndReturnOne(this ICall func, object that, params object[] objs)
        {
            Args args = new Args(objs);

            args.that = that;
            var ret = func.Call(args);

            return(ret.GetValueOrDefault(0));
        }
Beispiel #5
0
        public static void Main()
        {
            var   sAc  = new SitesAndCalls();
            ICall call = sAc;

            call.Call(Console.ReadLine().Split(' '));
            IBrowse browse = sAc;

            browse.Browse(Console.ReadLine().Split(' '));
        }
    public IEnumerator RunCoroutine()
    {
        while (true)
        {
            yield return(WaitObj.Obj);

            calledWorkObject?.Call();
            Event.Invoke();
        }
    }
Beispiel #7
0
        protected override List <object> _GetResults(Frame frame)
        {
            ICall func = caller.GetOneResult(frame) as ICall;

            if (func == null)
            {
                throw frame.NewRunException(caller.line, "expect fn or ext_fn to call");
            }

            var    args = this.args.GetArgs(frame);
            object that = caller is TableAccess? (caller as TableAccess).table : null;

            return(func.Call(args));
        }
Beispiel #8
0
 // This function will be called when the app pool has problem
 public void Notify(string message)
 {
     if (call != null)
     {
         call.Call(message);
     }
     if (email != null)
     {
         email.Email(message);
     }
     if (sms != null)
     {
         sms.Sms(message);
     }
 }
Beispiel #9
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;
        }
Beispiel #10
0
    /// <summary>
    /// Handler of call events.
    ///
    /// Can be customized in via subclasses.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected virtual void Call_CallEvent(object sender, CallEventArgs e)
    {
        switch (e.Type)
        {
        case CallEventType.CallAccepted:
            //Outgoing call was successful or an incoming call arrived
            Append("Connection established");
            mRemoteUserId = ((CallAcceptedEventArgs)e).ConnectionId;
            Debug.Log("New connection with id: " + mRemoteUserId
                      + " audio:" + mCall.HasAudioTrack(mRemoteUserId)
                      + " video:" + mCall.HasVideoTrack(mRemoteUserId));
            break;

        case CallEventType.CallEnded:
            //Call was ended / one of the users hung up -> reset the app
            Append("Call ended");
            InternalResetCall();
            break;

        case CallEventType.ListeningFailed:
            //listening for incoming connections failed
            //this usually means a user is using the string / room name already to wait for incoming calls
            //try to connect to this user
            //(note might also mean the server is down or the name is invalid in which case call will fail as well)
            mCall.Call(mUseAddress);
            break;

        case CallEventType.ConnectionFailed:
        {
            Byn.Media.ErrorEventArgs args = e as Byn.Media.ErrorEventArgs;
            Append("Connection failed error: " + args.ErrorMessage);
            InternalResetCall();
        }
        break;

        case CallEventType.ConfigurationFailed:
        {
            Byn.Media.ErrorEventArgs args = e as Byn.Media.ErrorEventArgs;
            Append("Configuration failed error: " + args.ErrorMessage);
            InternalResetCall();
        }
        break;

        case CallEventType.FrameUpdate:
        {
            //new frame received from webrtc (either from local camera or network)
            if (e is FrameUpdateEventArgs)
            {
                UpdateFrame((FrameUpdateEventArgs)e);
            }
            break;
        }

        case CallEventType.Message:
        {
            //text message received
            MessageEventArgs args = e as MessageEventArgs;
            Append(args.Content);
            break;
        }

        case CallEventType.WaitForIncomingCall:
        {
            //the chat app will wait for another app to connect via the same string
            WaitForIncomingCallEventArgs args = e as WaitForIncomingCallEventArgs;
            Append("Waiting for incoming call address: " + args.Address);
            break;
        }
        }
    }
Beispiel #11
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);
        }
    }
Beispiel #12
0
 private void Reconnect()
 {
     SetStatusMessageText("Reconnecting to " + account.address + "...");
     caller.Call(account.address);
 }
Beispiel #13
0
 public void Call(ICall photoMaker)
 {
     photoMaker.Call();
 }
    /// <summary>
    /// Handler of call events.
    ///
    /// Can be customized in via subclasses.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected virtual void Call_CallEvent(object sender, CallEventArgs e)
    {
        switch (e.Type)
        {
        case CallEventType.CallAccepted:
            //Outgoing call was successful or an incoming call arrived
            Append("Connection established");
            mRemoteUserId = ((CallAcceptedEventArgs)e).ConnectionId;
            Debug.Log("New connection with id: " + mRemoteUserId
                      + " audio:" + mCall.HasAudioTrack(mRemoteUserId)
                      + " video:" + mCall.HasVideoTrack(mRemoteUserId));
            break;

        case CallEventType.CallEnded:
            //Call was ended / one of the users hung up -> reset the app
            Append("Call ended");
            InternalResetCall();
            break;

        case CallEventType.ListeningFailed:
            //listening for incoming connections failed
            //this usually means a user is using the string / room name already to wait for incoming calls
            //try to connect to this user
            //(note might also mean the server is down or the name is invalid in which case call will fail as well)
            mCall.Call(mUseAddress);
            break;

        case CallEventType.ConnectionFailed:
        {
            Byn.Media.ErrorEventArgs args = e as Byn.Media.ErrorEventArgs;
            Append("Connection failed error: " + args.ErrorMessage);
            InternalResetCall();
        }
        break;

        case CallEventType.ConfigurationFailed:
        {
            Byn.Media.ErrorEventArgs args = e as Byn.Media.ErrorEventArgs;
            Append("Configuration failed error: " + args.ErrorMessage);
            InternalResetCall();
        }
        break;

        case CallEventType.FrameUpdate:
        {
            //new frame received from webrtc (either from local camera or network)
            if (e is FrameUpdateEventArgs)
            {
                UpdateFrame((FrameUpdateEventArgs)e);
            }
            break;
        }

        case CallEventType.Message:
        {
            //text message received
            MessageEventArgs args = e as MessageEventArgs;
            //Append(args.Content);
            // Debug.Log("Recieved: " + args.Content);
            //HandData data = JsonConvert.DeserializeObject<HandData>(args.Content);
            HandData data = JsonUtility.FromJson <HandData>(args.Content);
            //byte[] buffer = System.Text.Encoding.UTF8.GetBytes(args.Content);
            //HandData data = MessagePackSerializer.Deserialize<HandData>(buffer);
//                    if (data.IsRightHand) RemoteHandHold.RightHandDatas.Add(data);

            if (RemoteHead != null)
            {
                // RemoteHead.transform.position = data.HeadPosition;
                RemoteHead.transform.eulerAngles = data.HeadEulerAngles;
            }

            //if (RemoteHand != null)
            //{
            //    RemoteHand.transform.localPosition = data.LeapHand.PalmPosition.ToVector3();
            //}
            //if (IsLeftHand)
            //{
            //    RemotePalmL.transform.localPosition = data.LeapHand.PalmPosition.ToVector3();
            //    RemoteThumbL.transform.localPosition = data.LeapHand.GetThumb().TipPosition.ToVector3();
            //    RemoteIndexL.transform.localPosition = data.LeapHand.GetIndex().TipPosition.ToVector3();
            //    RemoteMiddleL.transform.localPosition = data.LeapHand.GetMiddle().TipPosition.ToVector3();
            //    RemoteRingL.transform.localPosition = data.LeapHand.GetRing().TipPosition.ToVector3();
            //    RemotePinkyL.transform.localPosition = data.LeapHand.GetPinky().TipPosition.ToVector3();
            //}
            //else
            //{
            //    RemotePalmR.transform.localPosition = data.LeapHand.PalmPosition.ToVector3();
            //    RemoteThumbR.transform.localPosition = data.LeapHand.GetThumb().TipPosition.ToVector3();
            //    RemoteIndexR.transform.localPosition = data.LeapHand.GetIndex().TipPosition.ToVector3();
            //    RemoteMiddleR.transform.localPosition = data.LeapHand.GetMiddle().TipPosition.ToVector3();
            //    RemoteRingR.transform.localPosition = data.LeapHand.GetRing().TipPosition.ToVector3();
            //    RemotePinkyR.transform.localPosition = data.LeapHand.GetPinky().TipPosition.ToVector3();
            //}

            RemotePalm.transform.localPosition   = data.PalmPosition;
            RemoteThumb.transform.localPosition  = data.ThumbPosition;
            RemoteIndex.transform.localPosition  = data.IndexPosition;
            RemoteMiddle.transform.localPosition = data.MiddlePosition;
            RemoteRing.transform.localPosition   = data.RingPosition;
            RemotePinky.transform.localPosition  = data.PinkyPosition;

            Debug.Log("RemotePalm: " + RemotePalm.transform.localPosition);

            if (!effectsManager.isMaster)
            {
                effectsManager.fader           = data.FaderValue;
                effectsManager.strengthControl = data.StrengthValue;
            }

            break;
        }

        case CallEventType.WaitForIncomingCall:
        {
            //the chat app will wait for another app to connect via the same string
            WaitForIncomingCallEventArgs args = e as WaitForIncomingCallEventArgs;
            Append("Waiting for incoming call address: " + args.Address);
            break;
        }
        }
    }