protected override void HandlePacket(PacketQueueEntry queueEntry) { try { switch (queueEntry.PacketId) { case PacketId.PACKET_ID_CAMERA_SYNC: CameraSyncPacket cameraPureSyncPacket = new CameraSyncPacket(); cameraPureSyncPacket.Read(queueEntry.Data); HandleCameraSyncPacket(queueEntry.Client, cameraPureSyncPacket); break; case PacketId.PACKET_ID_PLAYER_PURESYNC: PlayerPureSyncPacket playerPureSyncPacket = new PlayerPureSyncPacket(); playerPureSyncPacket.Read(queueEntry.Data); HandleClientPureSyncPacket(queueEntry.Client, playerPureSyncPacket); break; } } catch (Exception e) { Debug.WriteLine("Handling packet failed"); Debug.WriteLine(string.Join(", ", queueEntry.Data)); Debug.WriteLine($"{e.Message}\n{e.StackTrace}"); } }
protected override void HandlePacket(PacketQueueEntry queueEntry) { switch (queueEntry.PacketId) { case PacketId.PACKET_ID_LUA_EVENT: LuaEventPacket eventPacket = new LuaEventPacket(); eventPacket.Read(queueEntry.Data); var element = this.elementRepository.Get(eventPacket.ElementId); if (element == null) { this.logger.LogWarning($"'{eventPacket.Name}' event triggered on non-existant element {eventPacket.ElementId}"); break; } this.server.HandleLuaEvent(new Events.LuaEvent() { Player = queueEntry.Client.Player, Name = eventPacket.Name, Source = element, Parameters = eventPacket.LuaValues.ToArray() }); break; } }
protected override void HandlePacket(PacketQueueEntry queueEntry) { switch (queueEntry.PacketId) { case PacketId.PACKET_ID_COMMAND: CommandPacket commandPacket = new CommandPacket(); commandPacket.Read(queueEntry.Data); queueEntry.Client.Player.HandleCommand(commandPacket.Command, commandPacket.Arguments); break; } }
protected override void HandlePacket(PacketQueueEntry queueEntry) { switch (queueEntry.PacketId) { case PacketId.PACKET_ID_RPC: RpcPacket packet = new RpcPacket(); packet.Read(queueEntry.Data); HandleRpc(queueEntry.Client, packet); break; } }
protected override void HandlePacket(PacketQueueEntry queueEntry) { switch (queueEntry.PacketId) { case PacketId.PACKET_ID_PLAYER_JOIN: HandleClientJoin(queueEntry.Client); break; case PacketId.PACKET_ID_PLAYER_JOINDATA: PlayerJoinDataPacket joinDataPacket = new PlayerJoinDataPacket(); joinDataPacket.Read(queueEntry.Data); HandleClientJoinData(queueEntry.Client, joinDataPacket); break; case PacketId.PACKET_ID_PLAYER_QUIT: case PacketId.PACKET_ID_PLAYER_TIMEOUT: HandleClientQuit(queueEntry.Client); break; } }
protected abstract void HandlePacket(PacketQueueEntry queueEntry);