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; } }