29.6.3. Defining a server during a call
With the mobile client in standalone mode, you can use two application back ends at the same time: standalone server and main server. When a call is made, the system analyzes certain parameters and selects a server to be used based on the analysis results. The system analyzes the priority of use of a certain object and selected operation modes of the client application. This analysis is performed both for an explicit (for instance, when common module server method is called) and implicit server call (for instance, when a form is opened).
If a server call is initiated in the client application, the server is selected when the call is made. If further server calls are made inside such server call, the server is not changed. Consider some example that demonstrate such behavior.
For example, there is a catalog form called Goods whose priority of use is set to Standalone server. There is a common server module called SM1 whose priority is set to Main server. There is another server module called CM2that is not included in the standalone configuration.
Let us find out which server will be used when various actions are performed:
- The client application opens the Goods catalog form. Since the Standalone server priority is selected for this form, the form will be opened using a standalone server. Data to be displayed by that form is received from the standalone server, too.
- If any (context or non-context) form module server method is called in the Goods catalog item form, the method will be executed on the standalone server.
- If the SM1 common module method is called in the Goods catalog item form from the client method of form module, the main server is called or an exception is thrown. The call is executed if the standalone mobile application is connected to the main server, since the SM1 common module has the Main server priority.
- If the SM1 common module method is called from the server method of the Goods catalog item form, the standalone server will be used. This is due to the fact that a server call made from a server call uses a server which is selected for the first server call (standalone server in the example above).
- If a client method attempts to call the SM2 common module method in Goods catalog item form, similarly to the SM1 common module, the call will be made only if connection is established. This is due the fact that the SM2 common module is not included in the standalone configuration.
Despite everything mentioned above, you might need to change a server used to make a call. 1C:Enterprise allows you to do that upon any of the following:
- You need to call a server method of the main server from a method which is executed on the standalone server. In this case, use the MainServer global context property. If this property is used, common server modules of the main server are accessible on the standalone server. In this case, the call looks as follows: MainServer.ServerCommonModuleName.CommonModuleMethodName().
- On the client application side, you need to make a server call which uses either the main or standalone server irrespective of current parameters. To do this, use the following global context methods: SetUsedServer() or SetPreferableMainServerUse().
- A client application form has an attribute whose type is not included in the standalone configuration. In this case, when you open the form, the main server is used regardless of the server used to open the form where the attribute is displayed.