Esempio n. 1
0
 public void AddClient(TCPClientConnection client)
 {
     lock (fAddRemoveUsersLock)
     {
         try
         {
             if (!fConnectedClients.ContainsKey(client.IPAddress))
             {
                 fConnectedClients.Add(client.IPAddress, client);
             }
         }
         catch (Exception ex)
         {
         }
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Send data to all connected clients excepts sender.
 /// </summary>
 /// <param name="bytes">The byte array to be send.</param>
 /// <param name="offset">The position in the data buffer at witch to begin sending.</param>
 /// <param name="length">The number of the bytes to be send.</param>
 /// <param name="sender">The TCP client exception.</param>
 public void ReplyToAllExceptSender(byte[] bytes, int offset, int length, TCPClientConnection sender)
 {
     if (sender != null)
     {
         foreach (DictionaryEntry entry in fConnectedClients)
         {
             try
             {
                 TCPClientConnection tmp = (TCPClientConnection)entry.Value;
                 if (tmp.IPAddress != sender.IPAddress)
                 {
                     tmp.SendData(bytes, offset, length);
                 }
             }
             catch (Exception ex)
             {
             }
         }
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Send data to all connected clients excepts sender.
 /// </summary>
 /// <param name="data">The string to be send.</param>
 /// <param name="sender">The TCP client exception.</param>
 public void ReplyToAllExceptSender(string data, TCPClientConnection sender)
 {
     if (sender != null)
     {
         foreach (DictionaryEntry entry in fConnectedClients)
         {
             try
             {
                 TCPClientConnection tmp = (TCPClientConnection)entry.Value;
                 if (tmp.IPAddress != sender.IPAddress)
                 {
                     tmp.SendData(data);
                 }
             }
             catch (Exception ex)
             {
             }
         }
     }
 }
Esempio n. 4
0
        private void DoAcceptSocketCallback(IAsyncResult ar)
        {
            if (fThreadIsRunning)
            {
                try
                {
                    TcpListener listener = (TcpListener)ar.AsyncState;

                    TCPClientConnection client = new TCPClientConnection(listener.EndAcceptSocket(ar), fMyListener, fMyListener.IsMessageCollectorInUse, fMyListener.MessageSplitter);
                    if (fMyListener.ConnectedClients.Count >= fMyListener.MaxConnections)
                    {
                        client.DisconnectMe();
                    }
                }
                catch (Exception ex)
                {
                }

                DoListen();
            }
        }
Esempio n. 5
0
        private void DoAcceptSocketCallback(IAsyncResult ar)
        {
            if (fThreadIsRunning)
            {
                try
                {
                    TcpListener listener = (TcpListener)ar.AsyncState;

                    TCPClientConnection client = new TCPClientConnection(listener.EndAcceptSocket(ar), fMyListener, fMyListener.IsMessageCollectorInUse, fMyListener.MessageSplitter);
                    fClientConnectionCompleted.Set();

                    if (fMyListener.ConnectedClients.Count >= fMyListener.MaxConnections)
                    {
                        client.DisconnectMe();
                    }
                }
                catch (Exception ex)
                {
                }

                DoListen();
            }
        }
Esempio n. 6
0
 public void AddClient(TCPClientConnection client)
 {
     lock (fAddRemoveUsersLock)
     {
         try
         {
             if (!fConnectedClients.ContainsKey(client.IPAddress))
             {
                 fConnectedClients.Add(client.IPAddress, client);
             }
         }
         catch (Exception ex)
         {
         }
     }
 }
Esempio n. 7
0
        /// <summary>
        /// Send data to all connected clients excepts sender.
        /// </summary>
        /// <param name="bytes">The byte array to be send.</param>
        /// <param name="offset">The position in the data buffer at witch to begin sending.</param>
        /// <param name="length">The number of the bytes to be send.</param>
        /// <param name="sender">The TCP client exception.</param>
        public void ReplyToAllExceptSender(byte[] bytes, int offset, int length, TCPClientConnection sender)
        {
            if (sender != null)
            {
                foreach (DictionaryEntry entry in fConnectedClients)
                {
                    try
                    {
                        TCPClientConnection tmp = (TCPClientConnection)entry.Value;
                        if (tmp.IPAddress != sender.IPAddress)
                        {
                            tmp.SendData(bytes,offset,length);
                        }
                    }
                    catch (Exception ex)
                    {

                    }
                }
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Send data to all connected clients excepts sender.
        /// </summary>
        /// <param name="data">The string to be send.</param>
        /// <param name="sender">The TCP client exception.</param>
        public void ReplyToAllExceptSender(string data, TCPClientConnection sender)
        {
            if (sender != null)
            {
                foreach (DictionaryEntry entry in fConnectedClients)
                {
                    try
                    {
                        TCPClientConnection tmp = (TCPClientConnection)entry.Value;
                        if (tmp.IPAddress != sender.IPAddress)
                        {
                            tmp.SendData(data);
                        }
                    }
                    catch (Exception ex)
                    {

                    }
                }
            }
        }
Esempio n. 9
0
 /// <summary>
 /// Send data to all connected clients excepts sender.
 /// </summary>
 /// <param name="bytes">The byte array to be send.</param>
 /// <param name="offset">The position in the data buffer at witch to begin sending.</param>
 /// <param name="length">The number of the bytes to be send.</param>
 /// <param name="sender">The TCP client exception.</param>
 public virtual void ReplyToAllExceptSender(byte[] bytes, int offset, int length, TCPClientConnection sender)
 {
     for (int i = 0; i < fListeners.Count; i++)
     {
         try
         {
             ((TCPListener)fListeners[i]).ReplyToAllExceptSender(bytes,offset,length, sender);
         }
         catch (Exception ex)
         {
         }
     }
 }
Esempio n. 10
0
 /// <summary>
 /// Send data to all connected clients excepts sender.
 /// </summary>
 /// <param name="data">The string to be send.</param>
 /// <param name="sender">The TCP client exception.</param>
 public virtual void ReplyToAllExceptSender(string data, TCPClientConnection sender)
 {
     for (int i = 0; i < fListeners.Count; i++)
     {
         try
         {
             ((TCPListener)fListeners[i]).ReplyToAllExceptSender(data,sender);
         }
         catch (Exception ex)
         {
         }
     }
 }
Esempio n. 11
0
 /// <summary>
 /// Send data to a client.
 /// </summary>
 /// <param name="bytes">The byte array to be send.</param>
 /// <param name="offset">The position in the data buffer at witch to begin sending.</param>
 /// <param name="length">The number of the bytes to be send.</param>
 /// <param name="sender">The client to send the data.</param>
 public virtual void ReplyToSender(byte[] bytes, int offset, int length, TCPClientConnection sender)
 {
     sender.SendData(bytes, offset, length);
 }
Esempio n. 12
0
 /// <summary>
 /// Send data to a client.
 /// </summary>
 /// <param name="data">The string to send.</param>
 /// <param name="sender">The client to send the data.</param>
 public virtual void ReplyToSender(string data, TCPClientConnection sender)
 {
     sender.SendData(data);
 }
Esempio n. 13
0
 /// <summary>
 /// A client disconnects from this server.
 /// </summary>
 /// <param name="client"></param>
 public virtual void OnClientDisconnect(TCPClientConnection client)
 {
 }
Esempio n. 14
0
 /// <summary>
 /// Server is receiving data from a client connection.
 /// </summary>
 /// <param name="sender">The client sends the data to this server.</param>
 /// <param name="data">The incoming DataFrame.</param>
 public virtual void OnDataReceive(TCPClientConnection sender, DataFrame data)
 {
 }