示例#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.");
 }
示例#2
0
 public TwitterTcpServer(TcpEndPointDetails tcpEndPointDetails, ITwitterListener twitterListener)
 {
     _tcpEndPointDetails = tcpEndPointDetails;
     _twitterListener = twitterListener;
 }
示例#3
0
 public TwitterTcpListener(TcpEndPointDetails tcpEndpointDetails, ITwitterHandler twitterHandler, ILogger logger)
 {
     _tcpEndpointDetails = tcpEndpointDetails;
     _twitterHandler = twitterHandler;
     _logger = logger;
 }