Beispiel #1
0
 static void Main(string[] args)
 {
     Console.WriteLine("Starting Server...");
     TcpEndPointDetails tcpEndpointDetails = new TcpEndPointDetails { IpAddress = "127.0.0.1", Port = 10101 };
     using (ITwitterServer twitterServer = new TwitterTcpServer(
         tcpEndpointDetails, new TwitterTcpListener(tcpEndpointDetails,
             new TwitterHandler(),
             new ConsoleLogger())))
     {
         twitterServer.Start();
         Console.WriteLine("Server started.");
         Console.WriteLine("Type 'exit' to stop server.");
         string line = null;
         while ((line = Console.ReadLine()) != null)
         {
             if (line.ToLowerInvariant().Equals("exit"))
             {
                 break;
             }
         }
         Console.WriteLine("Stopping Server...");
     }
     Console.WriteLine("Server stopped.");
 }
 public TwitterTcpServer(TcpEndPointDetails tcpEndPointDetails, ITwitterListener twitterListener)
 {
     _tcpEndPointDetails = tcpEndPointDetails;
     _twitterListener = twitterListener;
 }
 public TwitterTcpListener(TcpEndPointDetails tcpEndpointDetails, ITwitterHandler twitterHandler, ILogger logger)
 {
     _tcpEndpointDetails = tcpEndpointDetails;
     _twitterHandler = twitterHandler;
     _logger = logger;
 }