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(); }
public void UnregisterSubscriber(TcpSubscriber subscriber) { _subscribers.Remove(subscriber); }
public void RegisterSubscriber(TcpSubscriber subscriber) { _subscribers.Add(subscriber); }