public void RemoveClient(SharpClient client) { this.slots[client.NetworkID] = null; client.SetIsConnected(false); clientCount--; connections.Remove(client); }
public void AssignClient(SharpClient client) { this.slots[client.NetworkID] = client; client.SetIsConnected(true); clientCount++; if (client.NetworkID != 0) { connections.Add(client); } }
public void Write(ref SharpSerializer ser) { ser.Write(this.room_name); ser.Write(this.room_password); ser.Write(this.max_connection); for (int i = 0; i < slots.Length; i++) { SharpClient c = slots[i]; bool isExist = (c != null); if (!isExist) { ser.Write(false); } else { ser.Write(true); c.Write(ref ser); } } }
private void Read(ref SharpSerializer ser) { this.room_name = ser.ReadString(); this.room_password = ser.ReadString(); this.max_connection = ser.ReadInt16(); this.slots = new SharpClient[this.max_connection]; for (int i = 0; i < slots.Length; i++) { bool isExist = ser.ReadBool(); if (isExist) { slots[i] = new SharpClient(ref ser); slots[i].SetIsConnected(true); if (i != 0) { connections.Add(slots[i]); } } else if (this.clientCount == 0) { this.clientCount = (short)i; } } }