Forward traffic between servers. HTTP Chat sample

Just add a easy way to allow to use different channels ranging the path

procedure THTTPChatServerMainForm.ROServerCustomResponseEvent(const aTransport: IROHTTPTransport; const aRequestStream,
  aResponseStream: TStream; const aResponse: IROHTTPResponse; var aHandled: Boolean);
var
  message_str: string;
begin
  // 6/16/2020 10:42 G.G -> accepts forward path following convention
  // forward_soap -> soap message
  // forward_bin  -> bin message
  // forward_json -> json message
  if pos('/forward',aTransport.PathInfo) = 1 then
  begin
    message_str := aTransport.PathInfo.Substring('/forward_'.Length, aTransport.PathInfo.Length);
    ForwardChannel.TargetUrl := 'http://127.0.0.1:9000/'+ message_str;
    (ForwardChannel as IROTransportChannel).Dispatch(aRequestStream, aResponseStream);
    aHandled := True;
  end;
end;

as result have two client app using different channels

HTH

best regards.

1 Like