void Disconnect(ClientConnectionComponent conn) { if (conn.state == State.Connected || conn.state == State.Initalize) { SendFinPacket(conn); conn.state = State.TearDown; } }
void SendFinPacket(ClientConnectionComponent conn) { ctx.CreateEntity() .AddComponent( NetworkComponentsLookup.SendPacket, new SendPacketComponent { target = conn.serverEP, packet = new Packet(PacketType.Fin, new byte[0]) }); }
void SendSyncPacket(ClientConnectionComponent conn) { var stream = new MemoryStream(); var writer = new BinaryWriter(stream); conn.playerMetadata.WriteBytes(writer); writer.Flush(); var metadataBytes = stream.ToArray(); ctx.CreateEntity() .AddSendPacket(conn.serverEP, new Packet(PacketType.Sync, metadataBytes)); }
void StartTearDown(ClientConnectionComponent conn) { conn.state = State.TearDown; SendFinPacket(conn); }
void SendAckPacket(ClientConnectionComponent conn, ushort playerID) { ctx.CreateEntity() .AddSendPacket(conn.serverEP, new Packet(PacketType.Ack, BitConverter.GetBytes(playerID))); }