private void InitializeInstanceFields()
 {
     pcObserver = new PCObserver(this);
     sdpObserver = new SDPObserver(this);
     gaeHandler = new GAEHandler(this);
     appRtcClient = new AppRTCClient(this, gaeHandler, this);
 }
 // Disconnect from remote resources, dispose of local resources, and exit.
 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();
     }
 }