Beispiel #1
0
 public void SendToAll(string package)
 {
     package = QEncryption.Encrypt(package);
     for (int i = 0; i < clients.Count; i++)
     {
         clients[i].SendWEncrypt(package);
     }
 }
Beispiel #2
0
        //DC all sockets!
        public void CloseAllSockets()
        {
            string dcAllPackage = PacketDatas.PACKET_FORCE_DC + PacketDatas.PACKET_SPLIT + "DC all command";

            dcAllPackage = QEncryption.Encrypt(dcAllPackage);
            while (clients.Count != 0)
            {
                //clients[0].Close();

                if (clients[0] == null || clients[0].isClosed)
                {
                    clients.RemoveAt(0);
                }
                else
                {
                    clients[0].Close();
                }
            }
        }
Beispiel #3
0
        public void Send(string dataToSend)
        {
            if (socket == null || !socket.Connected)
            {
                return;
            }

            dataToSend = QEncryption.Encrypt(dataToSend);
            dataToSend = PacketDatas.PACKET_HEADER + dataToSend;
            //We us UTF8 characterss so lets convert the bytes into utf8 string!
            byte[] dataBytes = Encoding.UTF8.GetBytes(dataToSend);
            //And then send it to our client.
            try
            {
                socket.Send(dataBytes, SocketFlags.None);
            }
            catch (Exception e)
            {
                Close();
            }
        }