internal bool IsNewerThan(NetworkPacket networkPacket) { return(this.Timestamp > networkPacket.Timestamp); }
private static void ProcessPing(NetworkPacket packet) { PingPacket ping = packet as PingPacket; }
internal static void SendToHost(NetworkPacket packet) { NetworkInterface.SendPacket(NetworkInterface.HostEndPoint, packet); }
public Task SendPacketTo(StreamSocket destinationSocket, NetworkPacket packet) { byte[] message = CreateMessageFromPacket(packet); return(SendTo(destinationSocket, message)); }
public Task SendPacketToAll(List <StreamSocket> destinationSockets, NetworkPacket packet) { byte[] message = CreateMessageFromPacket(packet); return(SendToAll(destinationSockets, message)); }
public async Task EnterLobby(string playerID) { NetworkPacket replyPacket = await SendLobbyCommand(playerID, LobbyCommands.EnterLobby, _myAddress); }
public Task SendPacketToHost(NetworkPacket packet) { return(SendPacketTo(_hostSocket, packet)); }
public static void SendPacket(IPEndPoint endpoint, NetworkPacket packet) { byte[] message = packet.CreateMessageFromPacket(); SendDataToClient(endpoint, message); }
internal PacketReceivedEventArgs(StreamSocket source, NetworkPacket packet) { Packet = packet; Source = source; }
public async Task InitializeGame(string playerID) { NetworkPacket replyPacket = await SendLobbyCommand(playerID, LobbyCommands.SetupGame); }
private static void OnPacketReceived(IPEndPoint source, NetworkPacket packet) { PacketReceived?.Invoke(null, new PacketReceivedEventArgs(source, packet)); }
public async Task LeaveGame(string playerID) { NetworkPacket replyPacket = await SendLobbyCommand(playerID, LobbyCommands.LeaveGame); }
public async Task JoinGame(string playerID, string hostID) { NetworkPacket replyPacket = await SendLobbyCommand(playerID, LobbyCommands.JoinGame, hostID); }
public async Task HostGame(string playerID) { NetworkPacket replyPacket = await SendLobbyCommand(playerID, LobbyCommands.HostGame, _myAddress); }
internal PacketReceivedEventArgs(IPEndPoint source, NetworkPacket packet) { Packet = packet; SourceIP = source; }
private void OnPacketReceived(StreamSocket source, NetworkPacket packet) { PacketReceived?.Invoke(this, new PacketReceivedEventArgs(source, packet)); }
internal async void OnPacketReceived(object network, PacketReceivedEventArgs args) { StreamSocket source = args.Source; NetworkPacket packet = args.Packet; if (packet.Type == PacketType.LobbyCommand) { LobbyCommandPacket command = packet as LobbyCommandPacket; string playerID = command.PlayerID; if (Server) { switch ((int)command.Command) { case (int)LobbyCommands.EnterLobby: await ProcessEnterLobbyCommand(playerID, source.Information.RemoteAddress.DisplayName); break; case (int)LobbyCommands.LeaveLobby: ProcessLeaveLobbyCommand(playerID); break; case (int)LobbyCommands.HostGame: string hostIPAddress = command.Data; ProcessHostGameCommand(playerID, hostIPAddress); break; case (int)LobbyCommands.JoinGame: string hostID = command.Data; ProcessJoinGameCommand(playerID, hostID); break; case (int)LobbyCommands.LeaveGame: ProcessLeaveGameCommand(playerID); break; case (int)LobbyCommands.SetupGame: await ProcessSetupGameCommand(playerID); break; } await UpdateAllClients(); MenuManager.PlayerListChanged(); } else { switch ((int)command.Command) { case (int)LobbyCommands.EjectThisUser: ProcessEjectThisUserCommand(); break; } } } else if (packet.Type == PacketType.LobbyData && !Server) { LobbyData data = packet as LobbyData; _playerList = data._playerList; _gameList = data._gameList; MenuManager.PlayerListChanged(); } }
private Task SendUDPPacketToPlayer(PlayerData player, NetworkPacket packet) { return(_networkConnection.SendUDPData(player.IPAddress, player.Port, packet)); }