예제 #1
0
 private static void TcpServer()
 {
     TcpListener listener = new TcpListener(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9900));
     listener.Start(1);
     var tcpClient = listener.AcceptTcpClient();
     using (var stream = tcpClient.GetStream())
     {
         byte[] buffer = new byte[2048];
         Serializer serializer = new Serializer();
         MessageBroker messageBroker = new MessageBroker();
         messageBroker.Subscribe<RequestMessage>(RequestHandler);
         MessageProcessor processor = new MessageProcessor(messageBroker, serializer);
         StreamHandler handler = new StreamHandler(processor, Guid.NewGuid());
         var read = stream.Read(buffer, 0, 2048);
         while (read > 0)
         {
             handler.ParseStream(buffer, 0, read);
             read = stream.Read(buffer, 0, 2048);
         }
     }
 }
예제 #2
0
 public WorkContext(ISubscription subscription, MessageBroker broker)
 {
     Subscription = subscription;
     Broker = broker;
 }