mirror of
https://github.com/Sanae6/SmoOnlineServer.git
synced 2024-11-25 04:35:18 +00:00
Send connect packets to new connection for other players
This commit is contained in:
parent
6771707dae
commit
351304f99f
2 changed files with 16 additions and 1 deletions
|
@ -138,6 +138,21 @@ public class Server {
|
||||||
// done disconnecting and removing stale clients with the same id
|
// done disconnecting and removing stale clients with the same id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
List<Client> otherConnectedPlayers = Clients.FindAll(c => c.Id != header.Id && c.Connected && c.Socket != null);
|
||||||
|
await Parallel.ForEachAsync(otherConnectedPlayers, async (other, _) => {
|
||||||
|
IMemoryOwner<byte> connectBuffer = MemoryPool<byte>.Shared.Rent(256);
|
||||||
|
PacketHeader connectHeader = new PacketHeader() {
|
||||||
|
Id = other.Id,
|
||||||
|
Type = PacketType.Connect
|
||||||
|
};
|
||||||
|
MemoryMarshal.Write(connectBuffer.Memory.Span, ref connectHeader);
|
||||||
|
ConnectPacket connectPacket = new ConnectPacket() {
|
||||||
|
ConnectionType = ConnectionTypes.FirstConnection // doesn't matter what it is :)
|
||||||
|
};
|
||||||
|
MemoryMarshal.Write(connectBuffer.Memory.Span, ref connectPacket);
|
||||||
|
await client.Send(connectBuffer.Memory);
|
||||||
|
connectBuffer.Dispose();
|
||||||
|
});
|
||||||
|
|
||||||
Logger.Info($"Client {socket.RemoteEndPoint} ({client.Id}) connected.");
|
Logger.Info($"Client {socket.RemoteEndPoint} ({client.Id}) connected.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ using Shared;
|
||||||
using Shared.Packet;
|
using Shared.Packet;
|
||||||
using Shared.Packet.Packets;
|
using Shared.Packet.Packets;
|
||||||
|
|
||||||
TcpClient client = new TcpClient("127.0.0.1", 1027);
|
TcpClient client = new TcpClient(args[0], 1027);
|
||||||
Guid ownId = new Guid(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
Guid ownId = new Guid(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||||
Guid otherId = Guid.Empty;
|
Guid otherId = Guid.Empty;
|
||||||
Logger logger = new Logger("Client");
|
Logger logger = new Logger("Client");
|
||||||
|
|
Loading…
Reference in a new issue