예제 #1
0
        /// <summary>
        /// Handler of connection to the ETServer
        /// Reads data from the stream, and answers accordingly.
        /// Deals with the tracker aswell using the ITracker interface.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="tracker_type"></param>
        /// <param name="clientId"></param>
        /// <param name="stream"></param>
        /// <param name="description"></param>
        public ConnectionHandler(byte name, string tracker_type, string clientId, NetworkStream stream, string description)
        {
            this.name = name;

            logger = LogManager.GetLogger(this.GetType());
            log4net.ThreadContext.Properties["id"] = "Id: " + clientId;

            this.stream = stream;
            readerWriter = new EriverStreamReaderWriter(stream);
            this.stop = new ManualResetEvent(false);
            tracker = TrackerFactory.GetTracker(tracker_type, name);
            Description = description;
        }
예제 #2
0
        public ConnectionHandler(byte name, string clientId, Stream stream, ManualResetEvent shutdown)
        {
            // TODO: Complete member initialization
            this.name = name;

            logger = LogManager.GetLogger(this.GetType());
            log4net.ThreadContext.Properties["id"] = "Id: " + clientId;

            this.stream = stream;
            readerWriter = new EriverStreamReaderWriter(stream);
            this.shutdown = shutdown;
            this.stop = new ManualResetEvent(false);
            tracker = TrackerFactory.GetTracker(name);
        }
예제 #3
0
        private void Connect_Button_Click(object sender, RoutedEventArgs e)
        {
            Console.WriteLine("Event! Connect to " + Host.Text.ToString() + ":" + Port.Text.ToString());
            if (client != null)
            {
                esrw = null;
                client.Close();
                client = null;
            }

            try
            {
                client = new TcpClient(Host.Text.ToString(), Convert.ToInt32(Port.Text.ToString()));
            }
            catch (SocketException)
            {
                MessageBox.Show("Error connecting to host. Please check that the other side is listening for requests on the port number.");
                return;
            }
            esrw = new EriverStreamReaderWriter(client.GetStream());
        }
예제 #4
0
 public void SetUp()
 {
     esrw = new EriverStreamReaderWriter(new MemoryStream(255));
 }