Difference between revisions of "RPC HELP Tutorial Step 2"

From VistApedia
Jump to: navigation, search
(Created page with "<h2>Tutorial: Step 2 -- Get Server/Port</h2> The TRPCBroker component you've added to your form is hard coded to access the Broker server and listener ...")
 
Line 1: Line 1:
 +
[[RPC_Broker_Help| RPC Broker Help Home]]
 +
 +
[[RPC_Broker_Help#Tutorial|Tutorial Home]]
 
<h2>Tutorial: Step 2 -- Get Server/Port</h2>
 
<h2>Tutorial: Step 2 -- Get Server/Port</h2>
 
The [[RPC_HELP_TRPCBroker|TRPCBroker]] component you've added to your form is hard coded to access the Broker server and listener port that it picks up from your own (developer) workstation (by default, BROKERSERVER and 9200). Naturally you don't want this to be the only server and port that your application can connect to. To retrieve the end-user workstation's designated Broker server and port to connect to, as stored in their Registry, you can use the [[RPC_HELP_GetServerInfo|GetServerInfo]] function.
 
The [[RPC_HELP_TRPCBroker|TRPCBroker]] component you've added to your form is hard coded to access the Broker server and listener port that it picks up from your own (developer) workstation (by default, BROKERSERVER and 9200). Naturally you don't want this to be the only server and port that your application can connect to. To retrieve the end-user workstation's designated Broker server and port to connect to, as stored in their Registry, you can use the [[RPC_HELP_GetServerInfo|GetServerInfo]] function.

Revision as of 20:44, 5 July 2015

RPC Broker Help Home

Tutorial Home

Tutorial: Step 2 -- Get Server/Port

The TRPCBroker component you've added to your form is hard coded to access the Broker server and listener port that it picks up from your own (developer) workstation (by default, BROKERSERVER and 9200). Naturally you don't want this to be the only server and port that your application can connect to. To retrieve the end-user workstation's designated Broker server and port to connect to, as stored in their Registry, you can use the GetServerInfo function.

To retrieve the end-user workstation's designated server and port:

  1. Include the RPCConf1 unit in your Pascal file's uses clause. This is the unit that GetServerInfo is a part of.
  2. Double-click on a blank region of the form. This creates an event handler procedure, TForm1.FormCreate, in your Pascal source code.
  3. Add code to the FormCreate event handler that retrieves the correct server and port to connect to, using the GetServerInfo function. If mrCancel is returned, your code should quit. Otherwise, your code should then set brkrRPCBroker1's Server and ListenerPort properties to the returned values.

The code should look like the following:

   procedure TForm1.FormCreate(Sender: TObject);
   var ServerStr: String;
     PortStr: String;
   begin
     // Get the correct port and server from the Registry.
     if GetServerInfo(ServerStr,PortStr)<> mrCancel then begin
       brkrRPCBroker1.Server:=ServerStr;
       brkrRPCBroker1.ListenerPort:=StrToInt(PortStr);
       {connectOK}
     end else begin
       Application.Terminate;    
     end;
   end;


Now that you have code to retrieve the appropriate RPC Broker server and listener port, in the next section of the tutorial (Step 3) your application will use the TRPCBroker component to establish a connection to the VistA M Server.

PREV: Step 1: Create Application with an RPC Broker Component

NEXT: Step 3: Establish Broker Connection