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();
        }
        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);
 }