void OnApplicationConnectionResult(CastClass.IApplicationConnectionResult result)
		{
			Console.WriteLine("ApplicationConnectionResultCallback - {0}", result.Status.StatusCode);
			if (result.Status.IsSuccess)
			{
				Console.WriteLine("application name: {0}, status: {1}, sessionId: {2}, wasLaunched: {3}",
					result.ApplicationMetadata.Name,
					result.ApplicationStatus,
					result.SessionId,
					result.WasLaunched);
				
				_applicationStarted = true;

				// Create the custom message
				// channel
				_channel = new MyChannel(_apiClient) { MessageReceived = OnMessageReceived };
					
				try {
					CastClass.CastApi.SetMessageReceivedCallbacks(
						_apiClient,
						MyChannel.CastNamespace,
						_channel);
				}
				catch (Exception e)
				{
					Console.WriteLine ("Exception while creating channel - {0}", e);
				}

				UpdateEnabledStates();
				_textName.RequestFocus ();
			}
			else
			{
				Console.WriteLine ("application could not launch");
				Teardown(true);
			}
		}
		void Teardown(bool selectDefaultRoute)
		{
			Console.WriteLine ("Teardown");

			if (_apiClient != null)
			{
				if (_applicationStarted)
				{
					_applicationStarted = false;
					_hasJoined = false;
					if (_apiClient.IsConnected || _apiClient.IsConnecting)
					{
						try
						{
							CastClass.CastApi.LeaveApplication(_apiClient);
							if (_channel != null)
							{
								CastClass.CastApi.RemoveMessageReceivedCallbacks(
									_apiClient,
									MyChannel.CastNamespace);
								_channel = null;
							}
						}
						catch (Exception e)
						{
							Console.WriteLine("Exception while removing channel - {0}", e);
						}
						_apiClient.Disconnect();
					}
				}
				_apiClient = null;
			}

			if (selectDefaultRoute)
			{
				_mediaRouter.SelectRoute(_mediaRouter.DefaultRoute);
			}
			_selectedDevice = null;

			_textGuess.Text = string.Empty;
			UpdateEnabledStates ();
		}