REGISTER CLIENT

4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next

version 6.5


REGISTER CLIENT (clientName{; period{; *}})

ParameterTypeDescription
clientNameStringName of the 4D Client session
periodLongintServer's interrogation period (in seconds)
**Local process

Description

The REGISTER CLIENT command "registers" a 4D Client station with the name specified in clientName on 4D Server, so as to allow other clients or eventually 4D Server (by using stored methods) to execute methods on it by using the EXECUTE ON CLIENT command. Once it is registered, a 4D Client can then execute one or more methods for other clients.

Note: You can also automatically register each client station that connects to 4D Server by using the "Register Clients at Startup..." option in the Preferences dialog box.

When this command is executed, a process, named clientName, is created on the client station. This process can only be aborted by the UNREGISTER CLIENT command.

If you pass the optional * parameter, the created process is local. 4D will automatically add the dollar sign ($) at the beginning of the process name. Otherwise, the process is global.

After executing the command, the client station will periodically ask 4D Server to see if another 4D Client or the server itself is calling it.

By default, this interrogation is done every two seconds. You can modify this time period by modifying period. The minimum value is one second.

Note: If this command is used with a single-user version of 4th Dimension, it has no effect.

Once the command is executed, it is not possible to modify 4D Client's name or the server's interrogation period on the fly. To do so, you must call the UNREGISTER CLIENT command, then the REGISTER CLIENT command.

Note: More than one 4D Client can have the same registered name.

If 4D Client is correctly registered, the OK system variable is equal to 1. If 4D Client was already registered, the command doesn't do anything and OK is equal to 0.

Examples

In the following example, we are going to create a small messaging system that allows the client workstations to communicate between themselves.

1. This method, Registration, allows you to register a 4D Client and to keep it ready to receive a message from another 4D Client:

      `You must unregister before registering under another name
   UNREGISTER CLIENT
   Repeat 
      vPseudoName:=Request("Enter your name:";"User";"OK";"Cancel")
   Until ((OK=0) | (vPseudoName # ""))
   If (OK=0)
      ...` Don't do anything
   Else 
      REGISTER CLIENT(vPseudoName)
   End if 

2. The following instruction allows you to get a list of the registered 4D Clients. It can be placed in the On Startup Database Method:

   PrClientList:=New process("4D Client List";32000;"List of registered clients")

3. The method 4D Client List allows you to recuperate all the registered 4D Clients and those that can receive messages:

   If (Application type=4D Client)
         ` the code below is only valid in client-server mode 
      $Ref:=Open window(100;100;300;400;-(Palette window+Has window title);"List of registered clients")
      Repeat 
         GET REGISTERED CLIENTS($ClientList;$ListeCharge)
            `Retrieve the registered clients in $ClientList
         ERASE WINDOW($Ref)
         GOTO XY(0;0)
         For ($p;1;Size of array($ClientList))
            MESSAGE($ClientList{$p}+Char(Carriage return))
         End for 
            `Display each second
         DELAY PROCESS(Current process;60)
      Until (False) ` Infinite loop
   End if

4. The following method allows you to send a message to another registered 4D Client. It calls the Display_Message method (see below).

   $Addressee:=Request("Addressee of the message:";"")
      ` Enter the name of the people visible in the window generated by the
      ` On Startup database method
   If (OK # 0)
      $Message:=Request("Message:")  ` message
      If (OK # 0)
         EXECUTE ON CLIENT($Addressee;"Display_Message";$Message) ` Send message
      End if 
   End if 

5. Here is the Display_Message method:

   C_TEXT($1)
   ALERT($1) 

6. Finally, this method allows a client station to no longer be visible by the other 4D Clients and to no longer receive messages:

   UNREGISTER CLIENT

See Also

EXECUTE ON CLIENT, GET REGISTERED CLIENTS, UNREGISTER CLIENT.

System Variables and Sets

If 4D Client is correctly registered, the OK system variable is equal to 1. If 4D Client was already registered, the command doesn't do anything and OK is equal to 0.


4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next