Пример #1
0
        /// <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;
            }));
        }
Пример #2
0
 void OnApplicationQuit()
 {
     if (loadBalancingClient != null)
     {
         loadBalancingClient.Disconnect();                               // don't forget to disconnect. unity doesn't like open sockets
     }
 }
Пример #3
0
 void OnApplicationQuit()
 {
     if (loadBalancingClient != null)
     {
         loadBalancingClient.Disconnect();
     }
 }
Пример #4
0
 public override void OnRoomListUpdate(List <RoomInfo> infos)
 {
     if (callback != null)
     {
         callback(infos);
     }
     client.Disconnect();
 }
Пример #5
0
        public void CloseRegionListView()
        {
            RegionsList = null;

            if (_lbc != null)
            {
                _lbc.Disconnect();
                _lbc = null;
            }

            _regionPingProcessActive = false;

            this.RegionListView.ResetList();
            this.ModalWindow.gameObject.SetActive(false);
        }
Пример #6
0
 public void Disconnect()
 {
     client.Disconnect();
 }