mirror of
https://github.com/Sanae6/SmoOnlineServer.git
synced 2024-11-25 12:45:18 +00:00
only send game packet on join to connected clients
This commit is contained in:
parent
72061215ce
commit
11015bd445
2 changed files with 2 additions and 1 deletions
|
@ -26,7 +26,7 @@ server.ClientJoined += (c, _) => {
|
|||
c.Metadata["scenario"] = (byte?) 0;
|
||||
c.Metadata["2d"] = false;
|
||||
c.Metadata["speedrun"] = false;
|
||||
foreach (Client client in server.Clients.Where(client => client.Metadata.ContainsKey("lastGamePacket")).ToArray()) {
|
||||
foreach (Client client in server.ClientsConnected) {
|
||||
try {
|
||||
c.Send((GamePacket) client.Metadata["lastGamePacket"]!, client).Wait();
|
||||
} catch {
|
||||
|
|
|
@ -10,6 +10,7 @@ namespace Server;
|
|||
|
||||
public class Server {
|
||||
public readonly List<Client> Clients = new List<Client>();
|
||||
public IEnumerable<Client> ClientsConnected => Clients.Where(client => client.Metadata.ContainsKey("lastGamePacket") && client.Connected);
|
||||
public readonly Logger Logger = new Logger("Server");
|
||||
private readonly MemoryPool<byte> memoryPool = MemoryPool<byte>.Shared;
|
||||
public Func<Client, IPacket, bool>? PacketHandler = null!;
|
||||
|
|
Loading…
Reference in a new issue