4D v14.3

REGISTER CLIENT

Home

 
4D v14.3
REGISTER CLIENT

REGISTER CLIENT 


 

REGISTER CLIENT ( clientName {; period}{; *} ) 
Parameter Type   Description
clientName  String in Name of the 4D client session
period  Longint in ***Ignored since version 11.3***
Operator in Local process

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.

Notes:

  • 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.
  • If this command is used with 4D in local mode, it has no effect.
  • More than one 4D client station can have the same registered name.

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.

Compatibility Note: Since version 11.3 of 4D, the server/client communication mechanisms have been optimized. Now the server sends execution requests directly to the registered clients when necessary (technology "push"). The previous principle where clients queried the server periodically is no longer used. The period parameter is ignored if it is passed.

Once the command is executed, it is not possible to modify a 4D client’s name on the fly. To do so, you must call the UNREGISTER CLIENT command, then the REGISTER CLIENT command.

Example  

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 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 Remote Mode)
  ` 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:

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

 
PROPERTIES 

Product: 4D
Theme: Processes
Number: 648

The OK variable is changed by the command

 
HISTORY 

Modified: 4D v11 SQL Release 3

 
SEE ALSO 

EXECUTE ON CLIENT
GET REGISTERED CLIENTS
UNREGISTER CLIENT

 
ARTICLE USAGE

4D Language Reference ( 4D v12.4)
4D Language Reference ( 4D v11 SQL Release 6)
4D Language Reference ( 4D v14 R3)
4D Language Reference ( 4D v14 R2)
4D Language Reference ( 4D v13.5)
4D Language Reference ( 4D v14.3)
4D Language Reference ( 4D v14 R4)