예제 #1
0
 public void Route(RequestContext requestContext)
 {
     if (requestContext.CurrentSocket.Connected && requestContext.IsValid())
     {
         RouteData routeData = FindMatchRouteData(requestContext);
         if (routeData != null)
         {
             Socket connectSocket = SocketUtil.Connect(routeData.TargetHostName, routeData.TargetPort);
             connectSocket.Send(requestContext.RequestMessageByte);
             byte[] recieveMessage = SocketUtil.Receive(connectSocket);
             requestContext.CurrentSocket.Send(recieveMessage);
         }
     }
 }
예제 #2
0
 private RouteData FindMatchRouteData(RequestContext requestContext)
 {
     return this.RouteTable.SingleOrDefault(item => item.SourceHostName.Equals(requestContext.RequestMessageHostName, StringComparison.CurrentCultureIgnoreCase) && item.SourcePort == requestContext.Port);
 }