private async void HandleMessage(WebSocketSession session, string message)
        {
            Models.SocketMessage msgObj;
            var command = message;

            try
            {
                msgObj  = JsonConvert.DeserializeObject <Models.SocketMessage>(message);
                command = msgObj.Command;
            }
            catch { }

            switch (command)
            {
            case "PokemonList":
                await PokemonListTask.Execute(_session);

                break;

            case "EggsList":
                await EggsListTask.Execute(_session);

                break;

            case "InventoryList":
                await InventoryListTask.Execute(_session);

                break;

            case "PlayerStats":
                await PlayerStatsTask.Execute(_session);

                break;
            }
        }
        private async void HandleMessage(WebSocketSession session, string message)
        {
            switch (message)
            {
            case "PokemonList":
                await PokemonListTask.Execute(_session);

                break;

            case "EggsList":
                await EggsListTask.Execute(_session);

                break;

            case "InventoryList":
                await InventoryListTask.Execute(_session);

                break;
            }

            // Setup to only send data back to the session that requested it.
            try
            {
                dynamic decodedMessage = JObject.Parse(message);
                var     handle         = _websocketHandler?.Handle(_session, session, decodedMessage);
                if (handle != null)
                {
                    await handle;
                }
            }
            catch
            {
                // ignored
            }
        }
Beispiel #3
0
        public async Task <IState> Execute(ISession session, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            if (session.LogicSettings.AmountOfPokemonToDisplayOnStart > 0)
            {
                await DisplayPokemonStatsTask.Execute(session, cancellationToken);
            }
            await session.MapCache.UpdateMapDatas(session);

            Action <IEvent> action = (evt) => session.EventDispatcher.Send(evt);
            await PokemonListTask.Execute(session, action);

            await InventoryListTask.Execute(session, action);

            await session.Inventory.UpdatePokeDex();

            session.EventDispatcher.Send(new NoticeEvent
            {
                Message = session.Translation.GetTranslation(TranslationString.UpdatesAt) + " https://github.com/Lunat1q/Catchem-PoGo " + session.Translation.GetTranslation(TranslationString.DiscordLink) + " https://discord.me/Catchem"
            });

            //return new CheckTosState();
            return(new CheckTosState());
        }
        private async void RefreshItems(ISession curSession)
        {
            _inRefreshItems = true;
            Action <IEvent> action = (evt) => curSession.EventDispatcher.Send(evt);
            await InventoryListTask.Execute(curSession, action);

            _inRefreshItems = false;
        }
Beispiel #5
0
        private async void HandleMessage(WebSocketSession session, string message)
        {
            Models.SocketMessage msgObj = null;
            var command = message;

            try
            {
                msgObj  = JsonConvert.DeserializeObject <Models.SocketMessage>(message);
                command = msgObj.Command;
            }
            catch { }

            // Action request from UI should not be broadcasted to all client
            Action <IEvent> action = (evt) => session.Send(Serialize(evt));

            switch (command)
            {
            case "PokemonList":
                await PokemonListTask.Execute(_session, action);

                break;

            case "EggsList":
                await EggsListTask.Execute(_session, action);

                break;

            case "InventoryList":
                await InventoryListTask.Execute(_session, action);

                break;

            case "PlayerStats":
                await PlayerStatsTask.Execute(_session, action);

                break;

            case "GetPokemonSettings":
                await PokemonSettingsTask.Execute(_session, action);

                break;

            case "TransferPokemon":
                if (msgObj?.Data != null)
                {
                    await TransferPokemonTask.Execute(_session, ulong.Parse(msgObj?.Data));
                }
                break;

            case "EvolvePokemon":
                if (msgObj?.Data != null)
                {
                    await EvolveSpecificPokemonTask.Execute(_session, ulong.Parse(msgObj?.Data), default(CancellationToken));
                }
                break;
            }
        }
        private async void HandleMessage(WebSocketSession session, string message)
        {
            Models.SocketMessage msgObj = null;
            var command = message;

            Console.WriteLine(message);
            try
            {
                msgObj  = JsonConvert.DeserializeObject <Models.SocketMessage>(message);
                command = msgObj.Command;
            }
            catch (Exception ex) { Logger.Write(ex.Message, LogLevel.Error); }

            // Action request from UI should not be broadcasted to all client
            Action <IEvent> action = (evt) => session.Send(Serialize(evt));

            switch (command)
            {
            case "PokemonList":
                await PokemonListTask.Execute(_session, action);

                break;

            case "EggsList":
                await EggsListTask.Execute(_session, action);

                break;

            case "InventoryList":
                await InventoryListTask.Execute(_session, action);

                break;

            case "PlayerStats":
                await PlayerStatsTask.Execute(_session, action);

                break;

            case "GetPokemonSettings":
                await PokemonSettingsTask.Execute(_session, action);

                break;

            case "TransferPokemon":
                await TransferPokemonTask.Execute(_session, msgObj?.Data);

                break;

            case "EvolvePokemon":
                await EvolveSpecificPokemonTask.Execute(_session, msgObj?.Data);

                break;
            }
        }
        private async void HandleMessage(WebSocketSession session, string message)
        {
            switch (message)
            {
            case "PokemonList":
                await PokemonListTask.Execute(_session);

                break;

            case "EggsList":
                await EggsListTask.Execute(_session);

                break;

            case "InventoryList":
                await InventoryListTask.Execute(_session);

                break;

            case "PokemonSnipeList":
                await HumanWalkSnipeTask.ExecuteFetchData(_session);

                break;
            }

            // Setup to only send data back to the session that requested it.
            try
            {
                dynamic decodedMessage = JObject.Parse(message);
                var     handle         = _websocketHandler?.Handle(_session, session, decodedMessage);
                if (handle != null)
                {
                    await handle;
                }
            }
            catch (Exception ex)
            {
#if DEBUG
                //Logger.Write(ex.Message);
#endif
            }

            // When we first get a message from the web socket, turn off log buffering.
            // This allows us to flush out buffered LogEvent messages to the GUI.
            Logger.TurnOffLogBuffering();
        }
Beispiel #8
0
        public async Task <IState> Execute(ISession session, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            if (session.LogicSettings.AmountOfPokemonToDisplayOnStart > 0)
            {
                await DisplayPokemonStatsTask.Execute(session);
            }
            await session.MapCache.UpdateMapDatas(session);

            Action <IEvent> action = (evt) => session.EventDispatcher.Send(evt);
            await PokemonListTask.Execute(session, action);

            await InventoryListTask.Execute(session, action);

            return(new FarmState());
        }
 private async void RefreshItems()
 {
     Action <IEvent> action = (evt) => CurSession.EventDispatcher.Send(evt);
     await InventoryListTask.Execute(CurSession, action);
 }