Esempio n. 1
0
        public void ManageClient(Socket currentSocket)
        {
            var stream = new NetworkStream(currentSocket);
            var reader = new BinaryReader(stream);

            try
            {
                var command = reader.ReadString();

                if (command.Contains("watch"))
                {
                    var parsed = ParseCommand(command);

                    var endpoint = new IPEndPoint(IPAddress.Parse(parsed[1]), int.Parse(parsed[2]));

                    var subscriber = new TcpSubscriber(endpoint);
                    _provider.RegisterSubscriber(subscriber);
                }
                else
                {
                    Post(currentSocket, Request(command));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("400 - BAD REQUEST");
                Debug.WriteLine(ex.Message);
            }

            stream.Close();
        }
Esempio n. 2
0
        public void ManageClient(Socket currentSocket)
        {
            var stream = new NetworkStream(currentSocket);
            var reader = new BinaryReader(stream);

            try
            {
                var command = reader.ReadString();

                if (command.Contains("watch"))
                {
                    var parsed = ParseCommand(command);

                    var endpoint = new IPEndPoint(IPAddress.Parse(parsed[1]), int.Parse(parsed[2]));

                    var subscriber = new TcpSubscriber(endpoint);
                    _provider.RegisterSubscriber(subscriber);
                }
                else
                    Post(currentSocket, Request(command));
            }
            catch (Exception ex)
            {
                Console.WriteLine("400 - BAD REQUEST");
                Debug.WriteLine(ex.Message);
            }

            stream.Close();
        }
Esempio n. 3
0
 public void UnregisterSubscriber(TcpSubscriber subscriber)
 {
     _subscribers.Remove(subscriber);
 }
Esempio n. 4
0
 public void RegisterSubscriber(TcpSubscriber subscriber)
 {
     _subscribers.Add(subscriber);
 }
Esempio n. 5
0
 public void UnregisterSubscriber(TcpSubscriber subscriber)
 {
     _subscribers.Remove(subscriber);
 }
Esempio n. 6
0
 public void RegisterSubscriber(TcpSubscriber subscriber)
 {
     _subscribers.Add(subscriber);
 }