Appspotdemo.Mono.Droid.AppRTCDemoActivity.disconnectAndExit C# (CSharp) Method

disconnectAndExit() private method

private disconnectAndExit ( ) : void
return void
        private void disconnectAndExit()
        {
            lock (quit[0])
            {
                if (quit[0] == Boolean.True)
                {
                    return;
                }
                quit[0] = Boolean.True;
                if (pc != null)
                {
                    pc.Dispose();
                    pc = null;
                }
                if (appRtcClient != null)
                {
                    appRtcClient.sendMessage("{\"type\": \"bye\"}");
                    appRtcClient.disconnect();
                    appRtcClient = null;
                }
                if (videoSource != null)
                {
                    videoSource.Dispose();
                    videoSource = null;
                }
                if (factory != null)
                {
                    factory.Dispose();
                    factory = null;
                }
                Finish();
            }
        }

Usage Example

コード例 #1
0
 public void onMessage(string data)
 {
     try
     {
         JSONObject json = new JSONObject(data);
         string     type = (string)json.Get("type");
         if (type.Equals("candidate"))
         {
             IceCandidate candidate = new IceCandidate((string)json.Get("id"), json.GetInt("label"), (string)json.Get("candidate"));
             if (outerInstance.queuedRemoteCandidates != null)
             {
                 outerInstance.queuedRemoteCandidates.AddLast(candidate);
             }
             else
             {
                 outerInstance.pc.AddIceCandidate(candidate);
             }
         }
         else if (type.Equals("answer") || type.Equals("offer"))
         {
             SessionDescription sdp = new SessionDescription(SessionDescription.SessionDescriptionType.FromCanonicalForm(type), outerInstance.preferISAC((string)json.Get("sdp")));
             outerInstance.pc.SetRemoteDescription(outerInstance.sdpObserver, sdp);
         }
         else if (type.Equals("bye"))
         {
             outerInstance.logAndToast("Remote end hung up; dropping PeerConnection");
             outerInstance.disconnectAndExit();
         }
         else
         {
             throw new Exception("Unexpected message: " + data);
         }
     }
     catch (JSONException e)
     {
         throw new Exception("Error", e);
     }
 }