Aller au contenu principal
Version: 20 R5 BETA

Client/Server Management

4D Desktop applications can be used in a Client/Server configuration, either as merged client/server applications or as remote projects.

  • merged client/server applications are generated by the Build Application manager. They are used for application deployments.

  • remote projects are .4DProject files opened by 4D Server and accessed with 4D in remote mode. The server sends a .4dz version of the project (compressed format) to the remote 4D, thus structure files are read-only. This configuration is usually used for application testing.

Connecting to a remote project from the same machine as 4D Server allows modifying the project files. This specific feature allows to develop a client/server application in the same context as the deployment context.

Opening a merged client/server application

A merged client/server application is customized and its starting is simplified:

  • Pour lancer la partie serveur, l’utilisateur double-clique simplement sur l’application serveur : il n’est pas nécessaire de sélectionner le fichier projet. il n’est pas nécessaire de sélectionner le fichier projet.
  • Pour lancer la partie cliente, l’utilisateur double-clique simplement sur l’application cliente, qui se connecte directement à l’application serveur : il n’est pas nécessaire de choisir un serveur dans une boîte de dialogue de connexion.

These principles are detailed in the Build Application page.

Ouvrir un projet distant

La première fois que vous vous connectez à un projet 4D Server via un 4D distant, vous utiliserez généralement la boîte de dialogue de connexion standard. Thereafter, you will be able to connect directly using the Open Recent Projects menu or a 4DLink shortcut file.

Pour vous connecter à distance à un projet 4D Server :

  1. Effectuez l'une des opérations suivantes :
    • Select Connect to 4D Server in the Welcome Wizard dialog
    • Select Open/Remote Project... from the File menu or the Open toolbar button.

La boîte de dialogue de connexion à 4D Server apparaît. This dialog has three tabs: Recent, Available, and Custom.

If 4D Server is connected to the same subnetwork as the remote 4D, select Available. 4D Server includes a built-in broadcasting system that, by default, publishes the name of the 4D Server projects available over the network. La liste est triée par ordre d'apparition et est mise à jour dynamiquement.

To connect to a server from the list, double-click on its name or select it and click the OK button.

If the published project is not displayed in the Available list, select Custom. La page Personnalisé vous permet de vous connecter à un serveur publié sur le réseau en utilisant son adresse réseau et en lui attribuant un nom personnalisé.

  • Project name: Defines the local name of the 4D Server project. This name will be used in the Recent page when referring to the project.
  • Network address: The IP address of the machine where the 4D Server was launched.
    • If two servers are executed simultaneously on the same machine, the IP address must be followed by a colon and port number, for example: 192.168.92.104:19814.
    • Par défaut, le port de publication d'un 4D Server est 19813. Ce numéro peut être modifié dans les paramètres du projet.

The Activate development mode option opens the remote connection in a special read/write mode and requires to access the project folder from the remote 4D (compatibility option).

Once this page assigns a server, clicking the OK button will allow you to connect to the server.

Once a connection to the server has been established, the remote project will be listed on the Recent tab.

Mettre à jour des fichiers de projet sur le serveur

4D Server automatically creates and sends the remote machines a .4dz version of the .4DProject project file (not compressed) in interpreted mode.

  • An updated .4dz version of the project is automatically produced when necessary, i.e. when the project has been modified and reloaded by 4D Server. Le projet est rechargé :
    • automatiquement, lorsque la fenêtre de l'application 4D Server arrive à l'avant de l'OS ou lorsque l'application 4D sur la même machine enregistre une modification (voir ci-dessous).
    • when the RELOAD PROJECT command is executed. L'appel de cette commande est nécessaire lorsque, par exemple, vous avez extrait une nouvelle version du projet depuis la plateforme de contrôle de version.

Mettre à jour des fichiers de projet sur les machines distantes

Lorsqu'une version .4dz mise à jour du projet a été produite sur 4D Server, les machines 4D distantes connectées doivent se déconnecter et se reconnecter à 4D Server afin de bénéficier de la version mise à jour.

Using 4D and 4D Server on the same machine

Lorsque 4D se connecte à un 4D Server sur la même machine, l'application se comporte comme 4D en mode monoposte et l'environnement de développement permet d'éditer les fichiers du projet. This feature allows you to develop a client/server application in the same context as the deployment context.

When 4D connects to a 4D Server on the same machine, the development mode is automatically activated, whatever the opening option status.

Each time 4D performs a Save all action from the design environment (explicitly from File menu or implicitly by switching to application mode for example), 4D Server synchronously reloads project files. 4D attend que 4D Server termine le rechargement des fichiers du projet avant de continuer.

However, you need to pay attention to the following behavior differences compared to standard project architecture:

  • le dossier userPreferences.{username} utilisé par 4D ne correspond pas au même dossier utilisé par 4D Server dans le dossier projet. Au lieu de cela, il s'agit d'un dossier dédié, nommé "userPreferences", stocké dans le dossier système du projet (c'est-à-dire au même emplacement que lors de l'ouverture d'un projet .4dz).
  • le dossier utilisé par 4D pour les données dérivées n'est pas le dossier "DerivedData" du dossier projet. Il s'agit plutôt d'un dossier dédié nommé "DerivedDataRemote" situé dans le dossier système du projet.
  • le fichier catalog.4DCatalog n'est pas édité par 4D mais par 4D Server. Les informations du catalogue sont synchronisées à l'aide des requêtes client/serveur
  • le fichier directory.json n'est pas édité par 4D mais par 4D Server. Les informations du répertoire sont synchronisées à l'aide des requêtes client/serveur
  • 4D utilise ses propres composants internes et plug-ins au lieu de ceux de 4D Server.

Il n'est pas recommandé d'installer des plug-ins ou des composants au niveau de l'application 4D ou 4D Server.

Remote user sessions

On the server, the Session command returns a session object describing the current user session. This object is handled through the functions and properties of the Session class.

Utilisation

The session object allows you to get information about the remote user session. You can share data between all processes of the user session using the session.storage shared object.

For example, you can launch a user authentication and verification procedure when a client connects to the server, involving entering a code sent by e-mail or SMS into the application. You then add the user information to the session storage, enabling the server to identify the user. This way, the 4D server can access user information for all client processes, enabling customized code to be written according to the user's role.

Availability

The remote user session object is available from:

  • Project methods that have the Execute on Server attribute (they are executed in the "twinned" process of the client process),
  • Les Triggers,
  • On Server Open Connection and On Server Shutdown Connection database methods.
info

All stored procedures on the server share the same virtual user session. For more information, see this page on doc.4d.com.

See also (blog post)

4D remote session object with Client/Server connection and Stored procedure.