private async Task UpdateAllClients() { LobbyData data = new LobbyData(_playerList, _gameList); var destinations = from player in _playerList.Values select player.IPAddress; foreach (string address in destinations) { using (StreamSocket socket = await _connection.ConnectToTCP(address, NetworkPorts.LobbyClientPort)) { await _connection.SendTCPData(socket, data); } } }
private async Task <NetworkPacket> ProcessRequest(StreamSocket socket, NetworkPacket packet) { AcknowledgePacket acknowledgement = new AcknowledgePacket(); if (packet.Type == PacketType.LobbyCommand) { LobbyCommandPacket command = packet as LobbyCommandPacket; await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { OnLobbyCommand(command); }); } else if (packet.Type == PacketType.LobbyData) { LobbyData lobbyData = packet as LobbyData; _playerList = lobbyData._playerList; _gameList = lobbyData._gameList; OnPropertyChanged("playerList"); OnPropertyChanged("gamesList"); } return(acknowledgement); }