/// <summary> /// Disconnects from Photon. /// </summary> /// <returns>An observable that resolves with a <see cref="DisconnectReason"/> after the matchmaker was disconnected</returns> /// <exception cref="InvalidOperationException"></exception> public virtual IObservable <DisconnectReason> Disconnect() { State = ConnectionState.Disconnecting; if (!_photonClient.IsConnected) { throw new InvalidOperationException("Cannot disconnect from Photon: Not connected"); } var cancel = Observable.FromEvent <OperationResponse>( handler => _photonClient.OpResponseReceived += handler, handler => _photonClient.OpResponseReceived -= handler ) .Where(response => response.ReturnCode != 0) .First() .Subscribe(response => { _disconnectedSubject.OnError(new ConnectionException("Cannot disconnect from Photon.", DisconnectReason.Exception)); }); _photonClient.Disconnect(); return(_disconnectedSubject.AsObservable().First().Select(c => { cancel.Dispose(); return c; })); }
void OnApplicationQuit() { if (loadBalancingClient != null) { loadBalancingClient.Disconnect(); // don't forget to disconnect. unity doesn't like open sockets } }
void OnApplicationQuit() { if (loadBalancingClient != null) { loadBalancingClient.Disconnect(); } }
public override void OnRoomListUpdate(List <RoomInfo> infos) { if (callback != null) { callback(infos); } client.Disconnect(); }
public void CloseRegionListView() { RegionsList = null; if (_lbc != null) { _lbc.Disconnect(); _lbc = null; } _regionPingProcessActive = false; this.RegionListView.ResetList(); this.ModalWindow.gameObject.SetActive(false); }
public void Disconnect() { client.Disconnect(); }