/// <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; } } }
/// <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; } } }