Пример #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();
        }
Пример #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();
        }
Пример #3
0
 public void UnregisterSubscriber(TcpSubscriber subscriber)
 {
     _subscribers.Remove(subscriber);
 }
Пример #4
0
 public void RegisterSubscriber(TcpSubscriber subscriber)
 {
     _subscribers.Add(subscriber);
 }
Пример #5
0
 public void UnregisterSubscriber(TcpSubscriber subscriber)
 {
     _subscribers.Remove(subscriber);
 }
Пример #6
0
 public void RegisterSubscriber(TcpSubscriber subscriber)
 {
     _subscribers.Add(subscriber);
 }