Example #1
0
        internal void Close(int serverID, int clientID)
        {
            OuterClient outerClient = this.clientList[this.GetClientIndex(clientID)];

            if (outerClient.ID == clientID)
            {
                outerClient.CloseServer(serverID);
            }
        }
Example #2
0
        internal bool SendToClient(int clientID, Packet packet)
        {
            OuterClient outerClient = this.clientList[this.GetClientIndex(clientID)];

            if (outerClient.ID == clientID)
            {
                outerClient.Transmit(packet);
                return(true);
            }
            return(false);
        }
Example #3
0
 internal void ProcessOuterClientDisconnect(OuterClient client)
 {
     if (this.clientList[client.Index].ID == client.ID)
     {
         this.clientList[client.Index] = new OuterClient(this, this.GetNextClientID(client.ID));
         this.clientCount--;
         if (this.clientTailIndex != -1)
         {
             this.clientList[this.clientTailIndex].NextIndex = client.Index;
         }
         else
         {
             this.clientHeadIndex = client.Index;
         }
         this.clientTailIndex = client.Index;
     }
 }
Example #4
0
        public void AddOuterClient(TcpClient tcpClient)
        {
            if (!tcpClient.Connected)
            {
                throw new ArgumentException("OuterClient not connected.");
            }
            if (this.clientHeadIndex == -1)
            {
                throw new IndexOutOfRangeException("Client count limit exceed. Can't add more client.");
            }
            OuterClient outerClient = this.clientList[this.clientHeadIndex];

            outerClient.Activate(tcpClient);
            this.clientCount++;
            for (int i = 0; i < this.autoConnectServerList.Count; i++)
            {
                outerClient.OpenServer(this.autoConnectServerList[i]);
            }
            this.clientHeadIndex = outerClient.NextIndex;
            if (this.clientHeadIndex == -1)
            {
                this.clientTailIndex = -1;
            }
        }