JMap Server Lima
JMap Server SDK
JMap Server SDK
  • Welcome to JMap Server SDK
  • General Concepts
  • JMap Pro and JMap Server Development
    • JMap Pro
      • Class Model
      • Map Elements
      • Coordinate Systems
      • Views and View Manager
      • Layers and Layer Manager
      • JMap Pro Application
      • Client-Server Communication
      • List of GUI Components
      • JMap Tools
      • JMap Pro Extensions
      • Integrating JMap Pro With Other Applications
      • References
    • JMap Server
      • JMap Server Extensions
    • JMap 7 API
    • JMap Pro Extension Builder
  • JMap Web Development
    • JMap Web Extensions
      • Programming JMap Web extensions
      • Sending Server Requests and Custom Actions
      • Default JMap Web Actions
      • Deploying JMap Web Extensions
    • Embedding a JMap Web Deployment Into Your own Application
Propulsé par GitBook

K2 Geospatial 2024

Sur cette page
  • Response status
  • Sending requests to JMap Server
Exporter en PDF
  1. JMap Pro and JMap Server Development
  2. JMap Pro

Client-Server Communication

PrécédentJMap Pro ApplicationSuivantList of GUI Components

Dernière mise à jour il y a 6 mois

When JMap Pro opens, a connection to the associated JMap Server is established. This connection is used to direct the various system requests, including requests to load the project configuration and data as well as .

Communication between a JMap Pro (desktop) application and JMap Server is done by exchanging requests and responses. The requests and the responses are in fact serialized objects that must normally be programmed, and these objects will contain the properties required to execute the request and return the information to the client. For example, an application managing citizen requests might have a request and response with the following properties:

Request

Response

Name of requesterType of requestDescriptionx and y coordinates of the request’s location

Status of the saved request in the database Unique identifier generated upon save

Response status

Your extension should always check the status of a response before using it. If the status is not equal to JMapSRV_STS_SUCCESS, a special treatment should be done in order to manage the error situation. In this case, the getMessage() method allows you to generate a message explaining the cause of the error.

Sending requests to JMap Server

JMapSrvConnection jmapConn = JMapApplicationContext.getInstance().getConnection();

Method

Description

Sends the request passed as a parameter to JMap Server and returns the response generated by JMap Server or by a server extension. This is a blocking method. It is well suited to situations where one must wait for the server’s response before continuing.

The following code example shows how to use the executeRequest method.

MyRequest request = new MyRequest("This is a test", 555);

JMapSrvConnection jmapConn = JMapApplicationContext.getInstance().getConnection();

MyResponse response = (MyResponse)jmapConn.executeRequest(request); // Execution WILL block here

if (response.getStatus() == MyResponse.JMAPSRV_STS_SUCCESS)

{

// Do something useful with the response

}

else

{

// Handle error here

}

The following code example shows how to use the pushRequest method.

MyRequest request = new MyRequest("This is a test", 555);

request.setClient(new JMapRequestClient()

{

// Will be called when the response is received from JMapServer

@Override

public void callback(JMapRequest request, JMapResponse response)

{

if (response.getStatus() == MyResponse.JMAPSRV_STS_SUCCESS)

{

// Do something useful with the response

}

else

{

// Handle error here

}

}

});

JMapSrvConnection jmapConn = JMapApplicationContext.getInstance().getConnection(); jmapConn.pushRequest(request); // Execution WILL NOT block here

For more information, refer to the section.

Every response has a status that indicates if the request was executed successfully or if a problem occurred. The getStatus() method of the class allows you to get the status of the response. For the list of possible statuses and their description, refer to the documentation of the class.

The class is responsible for all communication between JMap client and JMap Server. The connection instance can be accessed using the JMap application context, as shown in the following example.

The following methods (inherited from the class) are used to send requests to JMap Server and to receive the responses.

Sends the request passed as a parameter to JMap Server. This method is non-blocking. When the response is received, the method of the client of the request is called. This method is well suited to situations where one must quickly give back control to the user and when one can process the response in an asynchronous manner.

JMapExtensionResponse
JMapExtensionResponse
JMapSrvConnection
JMapNetworkConnection
executeRequest()
pushRequest()
callback()
Programming Extension Requests
extension requests
Communication between JMap Pro application and JMap Server