{hidden}
DO NOT EDIT THE CONTENT OF THIS PAGE DIRECTLY, UNLESS YOU KNOW WHAT YOU'RE DOING.
		THE STRUCTURE OF THE CONTENT IS VITAL IN BEING ABLE TO EXTRACT CHANGES FROM THE PAGE AND MERGE THEM BACK INTO SERVOY SOURCE{hidden}
{sub-section:description|text=}The Maintenance plugin can be used in combination with the solution import hooks to execute business logic when importing solutions into the Servoy Application Server. The Maintenance plugin allows to programatically perform administrative tasks that can otherwise only be performed manually on the Servoy Admin page.

Next to that, the Maintenance plugin also allows the developer to take control over the data model modifications.

*Solution Import Hooks*
During solution import from the Servoy Admin Page, modules with certain name patterns are handled in a special way. Modules whose names start with "before_import" are handled as pre-import hooks. Their [onOpen|Solution#onOpen] event handlers are executed before the solution is actually imported. Similarly, modules whose names start with "after_import" are handled as post-import hooks. Their [onOpen|Solution#onOpen] event handlers are executed after the solution is actually imported.

If you have several modules that start with "before_import" or "after_import", they will be all handled in this way, but no handling order is guaranteed. It is recommended that you have at most one pre-import and at most one post-import hook in your exported solutions.

During the execution of the [onOpen|Solution#onOpen] event handlers from the pre-import and post-import hooks, any output printed with [application.output(...)|application#output] will be redirected to the import log, which you can see in the Servoy Admin page.

The pre-import and post-import hooks were introduced for allowing you to automatically perform administrative tasks on the server while importing solutions:
* Send messages to connected clients, or even kill connected clients.
* Put the server into maintenance mode for the duration of the solution import.
* Perform operations on databases.

These operations can be performed through the {{maintenance}} plugin, which is available since version 4.2 of Servoy. The {{maintenance}} plugin was designed specifically for being used with solution import hooks. Please consult its API documentation for specific details about available functions.

A typical scenario of using the solution import hooks is the following:
* Before importing the solution, connected clients are notified that an import will take place, then they are disconnected and then the server is put into maintenance mode, so that no new clients can connect during the import.
* The import is performed as usual.
* After the import is over, the server is taken out of maintenance mode, so that clients can connect again.

All these steps can be automated if you create a pre-import and a post-import hook module. The pre-import hook module can have the following function set as its [onOpen|Solution#onOpen] event handler:
{code:JavaScript}
function onBeforeImportSolutionOpen()
{
	application.output("Notifying and disconnecting connected clients...");
	plugins.maintenance.sendMessageToAllClients("A solution upgrade will take place on the server. You will be disconnected in 2 minutes.");
	application.sleep(2 * 60 * 1000);
	plugins.maintenance.sendMessageToAllClients("A solution upgrade will take place on the server. You will be disconnected NOW.");
	plugins.maintenance.shutDownAllClients();
	application.output("Putting server into maintenance mode...");
	plugins.maintenance.setMaintenanceMode(true);
	application.output("Proceeding to import...");
}
{code}
The function sends a notification to all connected clients, telling them that in two minutes (or any other amount of time that should be enough for clients to save any important data) they will be disconnected. The function waits for two minutes, then it sends another message to the clients, telling them that they will be immediately disconnected. Then all connected clients are killed and then the Server is put into maintenance mode. From this moment on, no new client will be able to connect to the Server.

The post-import hook module can have the following function as its {{onOpen}} event handler:
{code:JavaScript}
function onAfterImportSolutionOpen()
{
	application.output("Taking server out of maintenance mode.");
	plugins.maintenance.setMaintenanceMode(false);
	application.output("Clients can now connect to the server.");
}
{code}
This function takes the Server out of maintenance mode, so that clients can again connect to it.

*Modifying Database Structure and Content*
Using the Maintenance plugin, it is possible to programmatically modify the database structure. You can create and drop tables, and you can create and delete columns.

It can happen that when you upgrade your Servoy solution, you need to change the structure of the underlying database. Some columns may become obsolete, new columns may be needed, data may need to be reorganized, etc. You can automate all these tasks by using the Maintenance plugin in a pre-import hook.

For example the following function, set as handler for the onOpen even of a pre-import hook, will delete a no longer needed column from a table.
{code:JavaScript}
function onSolutionOpenBeforeImport()
{
	var server = plugins.maintenance.getServer("example_data")
	if (server) {
		var table = server.getTable("todo_list")
		if (table) {
			table.deleteColumn("todo_list_suggested_by")
			var result = server.synchronizeWithDB(table)
			if (result)
				application.output("'Suggested By' column removed.")
			else
				application.output("Something went wrong while deleting column.")
		}
		else {
			application.output("Table 'todo_list' cannot be found.")
		}
	}
	else {
		application.output("Server 'example_data' cannot be found.")
	}
}
{code}

The function tries to obtain a reference to the server where the table is stored. If successful, then it tries to obtain a reference to the table which holds the obsolete column. If this step is also successful, then it deletes the column. In order to make the change permanent, the table must be synchronized with the underlying database.

In pre-import and post-import hooks, besides changing the database structure, you can also change the database content. This is done in the classical way, by using the foundset API.{sub-section}\\{table:class=servoy sReturnTypes}{tr:style=height: 30px;}{th}Return Types{th}{tr}{tr}{td}{span:class=sWordList}[JSServer]{span}{span:class=sWordList}[JSTableObject]{span}{span:class=sWordList}[JSClientInformation]{span}{td}{tr}{table}\\{table:class=servoy sSummery}{colgroup}{column:width=80px}{column}{column}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=2}Method Summary{th}{tr}{tbody}{tr}{td}[JSClientInformation]\[]{td}{td}[#getConnectedClients]\()
Returns an array of JSClientInformation elements describing the clients connected to the server.{td}{tr}{tbody}{tbody}{tr}{td}[String]\[]{td}{td}[#getDataModelClonesFrom]\(serverName)
Retrieves a list with names of all database servers that have property DataModelCloneFrom equal to the parameter.{td}{tr}{tbody}{tbody}{tr}{td}[JSServer]{td}{td}[#getServer]\(serverName, mustBeEnabled, mustBeValid)
Retrieves an instance of JSServer corresponding to the server with the name specified through the "serverName" argument.{td}{tr}{tbody}{tbody}{tr}{td}[String]\[]{td}{td}[#getServerNames]\(mustBeEnabled, mustBeValid, sort, includeDuplicates)
Retrieves a list with the names of all available database servers.{td}{tr}{tbody}{tbody}{tr}{td}[Boolean]{td}{td}[#isInMaintenanceMode]\()
Returns true if the server is in maintenance mode, false otherwise.{td}{tr}{tbody}{tbody}{tr}{td}void{td}{td}[#sendMessageToAllClients]\(message)
Sends a message to all connected clients.{td}{tr}{tbody}{tbody}{tr}{td}void{td}{td}[#sendMessageToClient]\(clientId, message)
Sends a message to a specific client, identified by its clientId.{td}{tr}{tbody}{tbody}{tr}{td}void{td}{td}[#setMaintenanceMode]\(maintenanceMode)
Puts the server into/out of maintenance mode, depending on the boolean parameter that is specified (if the parameter is true, then the server will be put into maintenance mode; if the parameter is false, then the server will be put out of maintenance mode).{td}{tr}{tbody}{tbody}{tr}{td}void{td}{td}[#shutDownAllClients]\()
Shuts down all connected clients.{td}{tr}{tbody}{tbody}{tr}{td}void{td}{td}[#shutDownClient]\(clientId)
Shuts down a specific client, identified by its clientId.{td}{tr}{tbody}{table}\\{table:class=servoy sDetail}{colgroup}{column:width=100%}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=1}Method Details{th}{tr}{tbody:id=70BFC4A0-35F4-417D-B0B6-7F709FECF7E0}{tr:id=name}{td}h6.getConnectedClients{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[JSClientInformation]\[]{span}{span:id=iets|style=float: left; font-weight: bold;}getConnectedClients{span}{span:id=iets|style=float: left;}\(){span}{td}{tr}{tr:id=des}{td}{sub-section:70BFC4A0-35F4-417D-B0B6-7F709FECF7E0_des|text=|trigger=button}Returns an array of JSClientInformation elements describing the clients connected to the server.{sub-section}{sub-section:70BFC4A0-35F4-417D-B0B6-7F709FECF7E0_des|trigger=none|class=sIndent}Returns an array of JSClientInformation elements describing the clients connected to the server.{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=prs}{td}*Parameters*\\{sub-section:70BFC4A0-35F4-417D-B0B6-7F709FECF7E0_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:70BFC4A0-35F4-417D-B0B6-7F709FECF7E0_prs|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=ret}{td}*Returns*\\{sub-section:70BFC4A0-35F4-417D-B0B6-7F709FECF7E0_ret|text=|trigger=button}{sub-section}{sub-section:70BFC4A0-35F4-417D-B0B6-7F709FECF7E0_ret|trigger=none|class=sIndent}[JSClientInformation]\[]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:70BFC4A0-35F4-417D-B0B6-7F709FECF7E0_see|text=|trigger=button}{sub-section}{sub-section:70BFC4A0-35F4-417D-B0B6-7F709FECF7E0_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:70BFC4A0-35F4-417D-B0B6-7F709FECF7E0_see|text=|trigger=button}{sub-section}{sub-section:70BFC4A0-35F4-417D-B0B6-7F709FECF7E0_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:70BFC4A0-35F4-417D-B0B6-7F709FECF7E0_sam|text=|trigger=button}{code:language=javascript}
var clients = plugins.maintenance.getConnectedClients();
application.output("There are " + clients.length + " connected clients.");
for (var i = 0; i < clients.length; i++)
	application.output("Client has clientId '" + clients[i].getClientId() + "' and has connected from host '" + clients[i].getHostAddress() + "'.");
{code}{sub-section}{sub-section:70BFC4A0-35F4-417D-B0B6-7F709FECF7E0_sam|class=sIndent|trigger=none}{code:language=javascript}
var clients = plugins.maintenance.getConnectedClients();
application.output("There are " + clients.length + " connected clients.");
for (var i = 0; i < clients.length; i++)
	application.output("Client has clientId '" + clients[i].getClientId() + "' and has connected from host '" + clients[i].getHostAddress() + "'.");
{code}{sub-section}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=7C12C8B5-6D69-42EA-9527-22B5159F5BC0}{tr:id=name}{td}h6.getDataModelClonesFrom{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[String]\[]{span}{span:id=iets|style=float: left; font-weight: bold;}getDataModelClonesFrom{span}{span:id=iets|style=float: left;}\(serverName){span}{td}{tr}{tr:id=des}{td}{sub-section:7C12C8B5-6D69-42EA-9527-22B5159F5BC0_des|text=|trigger=button}{sub-section}{sub-section:7C12C8B5-6D69-42EA-9527-22B5159F5BC0_des|trigger=none|class=sIndent}Retrieves a list with names of all database servers that have property DataModelCloneFrom equal to the parameter.{sub-section}{td}{tr}{tr:id=prs}{td}*Parameters*\\{sub-section:7C12C8B5-6D69-42EA-9527-22B5159F5BC0_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:7C12C8B5-6D69-42EA-9527-22B5159F5BC0_prs|trigger=none}serverName
{sub-section}{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:7C12C8B5-6D69-42EA-9527-22B5159F5BC0_ret|text=|trigger=button}{sub-section}{sub-section:7C12C8B5-6D69-42EA-9527-22B5159F5BC0_ret|trigger=none|class=sIndent}[String]\[]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:7C12C8B5-6D69-42EA-9527-22B5159F5BC0_see|text=|trigger=button}{sub-section}{sub-section:7C12C8B5-6D69-42EA-9527-22B5159F5BC0_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:7C12C8B5-6D69-42EA-9527-22B5159F5BC0_see|text=|trigger=button}{sub-section}{sub-section:7C12C8B5-6D69-42EA-9527-22B5159F5BC0_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:7C12C8B5-6D69-42EA-9527-22B5159F5BC0_sam|text=|trigger=button}{sub-section}{sub-section:7C12C8B5-6D69-42EA-9527-22B5159F5BC0_sam|class=sIndent|trigger=none}{code:language=javascript}
var serverNames = plugins.maintenance.getDataModelClonesFrom('my_server');
for (var i=0; i<serverNames.length; i++)
	application.output("Process server " + i + ": " + serverNames[i]);
{code}{sub-section}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=77371043-D691-4A90-A62E-5AF8B3C85C02}{tr:id=name}{td}h6.getServer{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[JSServer]{span}{span:id=iets|style=float: left; font-weight: bold;}getServer{span}{span:id=iets|style=float: left;}\(serverName, mustBeEnabled, mustBeValid){span}{td}{tr}{tr:id=des}{td}{sub-section:77371043-D691-4A90-A62E-5AF8B3C85C02_des|text=|trigger=button}{sub-section}{sub-section:77371043-D691-4A90-A62E-5AF8B3C85C02_des|trigger=none|class=sIndent}Retrieves an instance of JSServer corresponding to the server with the name specified through the "serverName" argument.
If the optional argument "mustBeEnabled" is set to true, then the JSServer instance is returned only if the server is active.
Similarly, if the "mustBeValid" optional argument is set to true, then the JSServer instance is returned only if the server is valid.
If the specified server is not found, or if it does not meet the requirements imposed by the optional arguments, then null is returned.
By default both optional arguments have the value false.{sub-section}{td}{tr}{tr:id=prs}{td}*Parameters*\\{sub-section:77371043-D691-4A90-A62E-5AF8B3C85C02_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:77371043-D691-4A90-A62E-5AF8B3C85C02_prs|trigger=none}serverName
\[mustBeEnabled\]
\[mustBeValid\]
{sub-section}{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:77371043-D691-4A90-A62E-5AF8B3C85C02_ret|text=|trigger=button}{sub-section}{sub-section:77371043-D691-4A90-A62E-5AF8B3C85C02_ret|trigger=none|class=sIndent}[JSServer]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:77371043-D691-4A90-A62E-5AF8B3C85C02_see|text=|trigger=button}{sub-section}{sub-section:77371043-D691-4A90-A62E-5AF8B3C85C02_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:77371043-D691-4A90-A62E-5AF8B3C85C02_see|text=|trigger=button}{sub-section}{sub-section:77371043-D691-4A90-A62E-5AF8B3C85C02_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:77371043-D691-4A90-A62E-5AF8B3C85C02_sam|text=|trigger=button}{sub-section}{sub-section:77371043-D691-4A90-A62E-5AF8B3C85C02_sam|class=sIndent|trigger=none}{code:language=javascript}
var server = plugins.maintenance.getServer("example_data");
if (server) {
	var tableNames = server.getTableNames();
	application.output("There are " + tableNames.length + " tables.");
	for (var i=0; i<tableNames.length; i++)
		application.output("Table " + i + ": " + tableNames[i]);
	}
else {
	plugins.dialogs.showInfoDialog("Attention","Server 'example_data' cannot be found.","OK");
}
{code}{sub-section}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=BD94C944-4028-4919-8B85-CFBB120DB5C3}{tr:id=name}{td}h6.getServerNames{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[String]\[]{span}{span:id=iets|style=float: left; font-weight: bold;}getServerNames{span}{span:id=iets|style=float: left;}\(mustBeEnabled, mustBeValid, sort, includeDuplicates){span}{td}{tr}{tr:id=des}{td}{sub-section:BD94C944-4028-4919-8B85-CFBB120DB5C3_des|text=|trigger=button}{sub-section}{sub-section:BD94C944-4028-4919-8B85-CFBB120DB5C3_des|trigger=none|class=sIndent}Retrieves a list with the names of all available database servers. The returned list will contain only enabled servers if the "mustBeEnabled"
optional argument is set to true. The list will contain only valid servers if the "mustBeValid" argument is set to true. If the "sort" optional
argument is set to true, then the list will be sorted alphabetically. If the "includeDuplicates" optional argument is set to false, then duplicate
servers will appear only once in the list. By default, the "mustBeEnabled" and the "mustBeValid" arguments have the value false, while the "sort"
and "includeDuplicates" arguments have the value true.{sub-section}{td}{tr}{tr:id=prs}{td}*Parameters*\\{sub-section:BD94C944-4028-4919-8B85-CFBB120DB5C3_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:BD94C944-4028-4919-8B85-CFBB120DB5C3_prs|trigger=none}\[mustBeEnabled\]
\[mustBeValid\]
\[sort\]
\[includeDuplicates\]
{sub-section}{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:BD94C944-4028-4919-8B85-CFBB120DB5C3_ret|text=|trigger=button}{sub-section}{sub-section:BD94C944-4028-4919-8B85-CFBB120DB5C3_ret|trigger=none|class=sIndent}[String]\[]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:BD94C944-4028-4919-8B85-CFBB120DB5C3_see|text=|trigger=button}{sub-section}{sub-section:BD94C944-4028-4919-8B85-CFBB120DB5C3_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:BD94C944-4028-4919-8B85-CFBB120DB5C3_see|text=|trigger=button}{sub-section}{sub-section:BD94C944-4028-4919-8B85-CFBB120DB5C3_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:BD94C944-4028-4919-8B85-CFBB120DB5C3_sam|text=|trigger=button}{sub-section}{sub-section:BD94C944-4028-4919-8B85-CFBB120DB5C3_sam|class=sIndent|trigger=none}{code:language=javascript}
var serverNames = plugins.maintenance.getServerNames();
application.output("There are " + serverNames.length + " servers.");
for (var i=0; i<serverNames.length; i++)
	application.output("Server " + i + ": " + serverNames[i]);
{code}{sub-section}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=3DBC6433-0FBC-4073-9936-36C41F697562}{tr:id=name}{td}h6.isInMaintenanceMode{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[Boolean]{span}{span:id=iets|style=float: left; font-weight: bold;}isInMaintenanceMode{span}{span:id=iets|style=float: left;}\(){span}{td}{tr}{tr:id=des}{td}{sub-section:3DBC6433-0FBC-4073-9936-36C41F697562_des|text=|trigger=button}{sub-section}{sub-section:3DBC6433-0FBC-4073-9936-36C41F697562_des|trigger=none|class=sIndent}Returns true if the server is in maintenance mode, false otherwise.{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=prs}{td}*Parameters*\\{sub-section:3DBC6433-0FBC-4073-9936-36C41F697562_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:3DBC6433-0FBC-4073-9936-36C41F697562_prs|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=ret}{td}*Returns*\\{sub-section:3DBC6433-0FBC-4073-9936-36C41F697562_ret|text=|trigger=button}{sub-section}{sub-section:3DBC6433-0FBC-4073-9936-36C41F697562_ret|trigger=none|class=sIndent}[Boolean]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:3DBC6433-0FBC-4073-9936-36C41F697562_see|text=|trigger=button}{sub-section}{sub-section:3DBC6433-0FBC-4073-9936-36C41F697562_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:3DBC6433-0FBC-4073-9936-36C41F697562_see|text=|trigger=button}{sub-section}{sub-section:3DBC6433-0FBC-4073-9936-36C41F697562_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:3DBC6433-0FBC-4073-9936-36C41F697562_sam|text=|trigger=button}{sub-section}{sub-section:3DBC6433-0FBC-4073-9936-36C41F697562_sam|class=sIndent|trigger=none}{code:language=javascript}
if (plugins.maintenance.isInMaintenanceMode())
	application.output("Server is in maintenance mode.");
else
	application.output("Server is not in maintenance mode.");
{code}{sub-section}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=40C39468-BE55-4237-8437-228A7D709B3D}{tr:id=name}{td}h6.sendMessageToAllClients{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}void{span}{span:id=iets|style=float: left; font-weight: bold;}sendMessageToAllClients{span}{span:id=iets|style=float: left;}\(message){span}{td}{tr}{tr:id=des}{td}{sub-section:40C39468-BE55-4237-8437-228A7D709B3D_des|text=|trigger=button}{sub-section}{sub-section:40C39468-BE55-4237-8437-228A7D709B3D_des|trigger=none|class=sIndent}Sends a message to all connected clients.{sub-section}{td}{tr}{tr:id=prs}{td}*Parameters*\\{sub-section:40C39468-BE55-4237-8437-228A7D709B3D_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:40C39468-BE55-4237-8437-228A7D709B3D_prs|trigger=none}message
{sub-section}{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:40C39468-BE55-4237-8437-228A7D709B3D_ret|text=|trigger=button}{sub-section}{sub-section:40C39468-BE55-4237-8437-228A7D709B3D_ret|trigger=none|class=sIndent}void{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:40C39468-BE55-4237-8437-228A7D709B3D_see|text=|trigger=button}{sub-section}{sub-section:40C39468-BE55-4237-8437-228A7D709B3D_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:40C39468-BE55-4237-8437-228A7D709B3D_see|text=|trigger=button}{sub-section}{sub-section:40C39468-BE55-4237-8437-228A7D709B3D_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:40C39468-BE55-4237-8437-228A7D709B3D_sam|text=|trigger=button}{sub-section}{sub-section:40C39468-BE55-4237-8437-228A7D709B3D_sam|class=sIndent|trigger=none}{code:language=javascript}
plugins.maintenance.sendMessageToAllClients("Hello, all clients!");
{code}{sub-section}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=641412F9-8CFC-43CF-BD8F-57986C8C4685}{tr:id=name}{td}h6.sendMessageToClient{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}void{span}{span:id=iets|style=float: left; font-weight: bold;}sendMessageToClient{span}{span:id=iets|style=float: left;}\(clientId, message){span}{td}{tr}{tr:id=des}{td}{sub-section:641412F9-8CFC-43CF-BD8F-57986C8C4685_des|text=|trigger=button}{sub-section}{sub-section:641412F9-8CFC-43CF-BD8F-57986C8C4685_des|trigger=none|class=sIndent}Sends a message to a specific client, identified by its clientId. The clientIds are retrieved by calling the getConnectedClients method.{sub-section}{td}{tr}{tr:id=prs}{td}*Parameters*\\{sub-section:641412F9-8CFC-43CF-BD8F-57986C8C4685_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:641412F9-8CFC-43CF-BD8F-57986C8C4685_prs|trigger=none}clientId
message
{sub-section}{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:641412F9-8CFC-43CF-BD8F-57986C8C4685_ret|text=|trigger=button}{sub-section}{sub-section:641412F9-8CFC-43CF-BD8F-57986C8C4685_ret|trigger=none|class=sIndent}void{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:641412F9-8CFC-43CF-BD8F-57986C8C4685_see|text=|trigger=button}{sub-section}{sub-section:641412F9-8CFC-43CF-BD8F-57986C8C4685_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:641412F9-8CFC-43CF-BD8F-57986C8C4685_see|text=|trigger=button}{sub-section}{sub-section:641412F9-8CFC-43CF-BD8F-57986C8C4685_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:641412F9-8CFC-43CF-BD8F-57986C8C4685_sam|text=|trigger=button}{sub-section}{sub-section:641412F9-8CFC-43CF-BD8F-57986C8C4685_sam|class=sIndent|trigger=none}{code:language=javascript}
var clients = plugins.maintenance.getConnectedClients();
for (var i=0; i<clients.length; i++)
	plugins.maintenance.sendMessageToClient(clients[i].getClientId(), "Hello, client " + clients[i].getClientId() + "!");
{code}{sub-section}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=489947C5-06E9-4A9E-BEED-675A79C02BE5}{tr:id=name}{td}h6.setMaintenanceMode{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}void{span}{span:id=iets|style=float: left; font-weight: bold;}setMaintenanceMode{span}{span:id=iets|style=float: left;}\(maintenanceMode){span}{td}{tr}{tr:id=des}{td}{sub-section:489947C5-06E9-4A9E-BEED-675A79C02BE5_des|text=|trigger=button}{sub-section}{sub-section:489947C5-06E9-4A9E-BEED-675A79C02BE5_des|trigger=none|class=sIndent}Puts the server into/out of maintenance mode, depending on the boolean parameter that is specified (if the parameter is true, then the server will be put into maintenance mode; if the parameter is false, then the server will be put out of maintenance mode).{sub-section}{td}{tr}{tr:id=prs}{td}*Parameters*\\{sub-section:489947C5-06E9-4A9E-BEED-675A79C02BE5_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:489947C5-06E9-4A9E-BEED-675A79C02BE5_prs|trigger=none}maintenanceMode
{sub-section}{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:489947C5-06E9-4A9E-BEED-675A79C02BE5_ret|text=|trigger=button}{sub-section}{sub-section:489947C5-06E9-4A9E-BEED-675A79C02BE5_ret|trigger=none|class=sIndent}void{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:489947C5-06E9-4A9E-BEED-675A79C02BE5_see|text=|trigger=button}{sub-section}{sub-section:489947C5-06E9-4A9E-BEED-675A79C02BE5_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:489947C5-06E9-4A9E-BEED-675A79C02BE5_see|text=|trigger=button}{sub-section}{sub-section:489947C5-06E9-4A9E-BEED-675A79C02BE5_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:489947C5-06E9-4A9E-BEED-675A79C02BE5_sam|text=|trigger=button}{sub-section}{sub-section:489947C5-06E9-4A9E-BEED-675A79C02BE5_sam|class=sIndent|trigger=none}{code:language=javascript}
plugins.maintenance.setMaintenanceMode(!plugins.maintenance.isInMaintenanceMode());
{code}{sub-section}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=6EAB7235-0274-421B-8A4C-D928A3BA6422}{tr:id=name}{td}h6.shutDownAllClients{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}void{span}{span:id=iets|style=float: left; font-weight: bold;}shutDownAllClients{span}{span:id=iets|style=float: left;}\(){span}{td}{tr}{tr:id=des}{td}{sub-section:6EAB7235-0274-421B-8A4C-D928A3BA6422_des|text=|trigger=button}{sub-section}{sub-section:6EAB7235-0274-421B-8A4C-D928A3BA6422_des|trigger=none|class=sIndent}Shuts down all connected clients.{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=prs}{td}*Parameters*\\{sub-section:6EAB7235-0274-421B-8A4C-D928A3BA6422_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:6EAB7235-0274-421B-8A4C-D928A3BA6422_prs|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=ret}{td}*Returns*\\{sub-section:6EAB7235-0274-421B-8A4C-D928A3BA6422_ret|text=|trigger=button}{sub-section}{sub-section:6EAB7235-0274-421B-8A4C-D928A3BA6422_ret|trigger=none|class=sIndent}void{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:6EAB7235-0274-421B-8A4C-D928A3BA6422_see|text=|trigger=button}{sub-section}{sub-section:6EAB7235-0274-421B-8A4C-D928A3BA6422_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:6EAB7235-0274-421B-8A4C-D928A3BA6422_see|text=|trigger=button}{sub-section}{sub-section:6EAB7235-0274-421B-8A4C-D928A3BA6422_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:6EAB7235-0274-421B-8A4C-D928A3BA6422_sam|text=|trigger=button}{sub-section}{sub-section:6EAB7235-0274-421B-8A4C-D928A3BA6422_sam|class=sIndent|trigger=none}{code:language=javascript}
plugins.maintenance.shutDownAllClients();
{code}{sub-section}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=2449A036-FE2D-4765-9444-55AB5AD4C007}{tr:id=name}{td}h6.shutDownClient{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}void{span}{span:id=iets|style=float: left; font-weight: bold;}shutDownClient{span}{span:id=iets|style=float: left;}\(clientId){span}{td}{tr}{tr:id=des}{td}{sub-section:2449A036-FE2D-4765-9444-55AB5AD4C007_des|text=|trigger=button}{sub-section}{sub-section:2449A036-FE2D-4765-9444-55AB5AD4C007_des|trigger=none|class=sIndent}Shuts down a specific client, identified by its clientId. The clientIds are retrieved by calling the getConnectedClients method.{sub-section}{td}{tr}{tr:id=prs}{td}*Parameters*\\{sub-section:2449A036-FE2D-4765-9444-55AB5AD4C007_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:2449A036-FE2D-4765-9444-55AB5AD4C007_prs|trigger=none}clientId
{sub-section}{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:2449A036-FE2D-4765-9444-55AB5AD4C007_ret|text=|trigger=button}{sub-section}{sub-section:2449A036-FE2D-4765-9444-55AB5AD4C007_ret|trigger=none|class=sIndent}void{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:2449A036-FE2D-4765-9444-55AB5AD4C007_see|text=|trigger=button}{sub-section}{sub-section:2449A036-FE2D-4765-9444-55AB5AD4C007_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:2449A036-FE2D-4765-9444-55AB5AD4C007_see|text=|trigger=button}{sub-section}{sub-section:2449A036-FE2D-4765-9444-55AB5AD4C007_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:2449A036-FE2D-4765-9444-55AB5AD4C007_sam|text=|trigger=button}{sub-section}{sub-section:2449A036-FE2D-4765-9444-55AB5AD4C007_sam|class=sIndent|trigger=none}{code:language=javascript}
var clients = plugins.maintenance.getConnectedClients();
for (var i=0; i<clients.length; i++)
	plugins.maintenance.shutDownClient(clients[i].getClientId());
{code}{sub-section}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{table}