Пример #1
0
 private void ResetState()
 {
     _matchMakingProperties = null;
     _statusCallback        = null;
     _status = ClientStatusLegacy.Offline;
     _taskScheduler.Remove(_pingTask);
 }
Пример #2
0
        public ShamanClientPeerLegacy(IMessageDeserializer messageDeserializer, IShamanLogger logger, ITaskSchedulerFactory taskSchedulerFactory, int pollPackageQueueIntervalMs, ISerializer serializer, IRequestSender requestSender, bool startOtherThreadMessageProcessing = true, int maxPacketSize = 300, int sendTickMs = 33)
        {
            _status = ClientStatusLegacy.Offline;

            _messageDeserializer = messageDeserializer;
            _logger        = logger;
            _taskScheduler = taskSchedulerFactory.GetTaskScheduler();
            _serializer    = serializer;
//            _serializer.InitializeDefaultSerializers(0, "client");
            _clientPeer    = new ClientPeer(logger, taskSchedulerFactory, maxPacketSize, sendTickMs);
            _requestSender = requestSender;
            _clientPeer.OnDisconnectedFromServer += (reason) =>
            {
                switch (_status)
                {
                case ClientStatusLegacy.ConnectingGameServer:
                case ClientStatusLegacy.AuthorizingGameServer:
                case ClientStatusLegacy.JoiningRoom:
                case ClientStatusLegacy.InRoom:
                case ClientStatusLegacy.LeavingRoom:
                    OnDisconnectedFromGameServer?.Invoke(reason);
                    break;

                case ClientStatusLegacy.ConnectingMatchMaking:
                case ClientStatusLegacy.AuthorizingMatchMaking:
                case ClientStatusLegacy.JoiningMatchMaking:
                case ClientStatusLegacy.OnMatchMaking:
                case ClientStatusLegacy.LeavingMatchMaking:
                    OnDisconnectedFromMmServer?.Invoke(reason);
                    break;
                }
                OnDisconnected?.Invoke(reason);
                ResetState();
            };
            _pollPackageQueueIntervalMs = pollPackageQueueIntervalMs;

            if (startOtherThreadMessageProcessing)
            {
                StartProcessingMessagesLoop();
            }
        }
Пример #3
0
 private void SetAndReportStatus(ClientStatusLegacy status, Action <ConnectionStatusLegacy, JoinInfo> statusCallback = null, bool isSuccess = true, string error = "")
 {
     _status = status;
     statusCallback?.Invoke(new ConnectionStatusLegacy(status, isSuccess, error), JoinInfo);
 }
Пример #4
0
 public ConnectionStatusLegacy(ClientStatusLegacy status, bool isSuccess = true, string error = "")
 {
     Status    = status;
     Error     = error;
     IsSuccess = isSuccess;
 }