Example #1
0
        public static void AddNewClient(TcpClientIdentifier clientID, TcpClient tcpClient)
        {
            Client client = new Client(clientID, tcpClient);

            rwLock.EnterWriteLock();
            try {
                clients.Add(clientID, client);
            } finally {
                rwLock.ExitWriteLock();
            }
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TcpManager"/> class.
        /// </summary>
        public static void InitializeTcp()
        {
            if (tcpClient != null)
            {
                if (tcpClient.Socket.Connected)
                {
                    tcpClient.Close();
                }
                tcpClient.DataReceived -= new EventHandler <Tcp.DataReceivedEventArgs>(tcpClient_DataReceived);
            }
            tcpClient = new Tcp.TcpClient();
            tcpClient.CustomHeaderSize = GetCustomPacketHeaderSize();
            tcpClient.DataReceived    += new EventHandler <Tcp.DataReceivedEventArgs>(tcpClient_DataReceived);

            //packetSecurity.SetKey("abcdefgh76876bfgjhgfy8u7iy");
        }
Example #3
0
        public Client(TcpClientIdentifier tcpID, Tcp.TcpClient tcpClient)
        {
            this.tcpID     = tcpID;
            this.tcpClient = tcpClient;
            this.tcpClient.CustomHeaderSize = GetCustomPacketHeaderSize();
            packetModifiers = new PacketModifiers();

            //database = new MySql("localhost", 3306, "test", "root", "test");

#if EVENTTHREAD
            eventThread = new PlayerEventThread(this);
#endif

            AddEventHandlers();

            SetupPacketSecurity();
        }
Example #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TcpManager"/> class.
        /// </summary>
        public static void InitializeTcp()
        {
            if (tcpClient != null)
            {
                if (tcpClient.Socket.Connected)
                {
                    tcpClient.Close();
                }
                tcpClient.DataReceived -= new EventHandler<Tcp.DataReceivedEventArgs>(tcpClient_DataReceived);
            }
            tcpClient = new Tcp.TcpClient();
            tcpClient.CustomHeaderSize = GetCustomPacketHeaderSize();
            tcpClient.DataReceived += new EventHandler<Tcp.DataReceivedEventArgs>(tcpClient_DataReceived);

            //packetSecurity.SetKey("abcdefgh76876bfgjhgfy8u7iy");
        }
 public ConnectionReceivedEventArgs(Object id, TcpClient tcpClient)
 {
     this.tcpClient = tcpClient;
     this.id = id;
 }