A session to the MGP Server. More...
Public Member Functions | |
| void | connect (String host, int port, boolean useSsl) throws MgpException |
| Connect to the server. | |
| void | close () throws MgpException |
| Clears the session by logging off from the server and closing the current connection. | |
| void | sendOperation (int operation, OptionHolder options, boolean doFlush) throws MgpException |
| Send an operation to the EMG server. | |
| void | sendOperation (int operation, OptionHolder options) throws MgpException |
| Send an operation to the EMG server. | |
| int | readOperation (OptionHolder options) throws MgpException |
| Read an operation request from the server and store the options in the provided option holder. | |
| int | readResponse () throws MgpException |
| Read the response to the last command sent to the EMG server. | |
| OptionHolder | execute (int operation, OptionHolder options) throws MgpException |
| Send an operation with arguments to the EMG server, and wait for the response. | |
| void | login (String username, String password, String servicetype) throws MgpException |
| Login to the server using username and password for authentication. | |
| void | login (String username, String password) throws MgpException |
| Login to the server using username and password for authentication. | |
| void | logoff () throws MgpException |
| Logoff from the server. | |
| void | reload () throws MgpException |
| Reload the configuration on the server, while keeping the connection open. | |
| int | sendMessage (Message msg) throws MgpException |
| Send a message. | |
| int | queryMessage (int id) throws MgpException |
| Query the server for status of a message, identified by the specified id. | |
| void | deleteMessage (int id) throws MgpException |
| Delete a message. | |
| java.sql.ResultSet | dbexec (String profile, String sql) throws MgpException, java.sql.SQLException |
| Send an SQL string to be executed on the EMG server. | |
| boolean | isAdmin () |
| Returns whether user in session is an administrator. | |
| int | getAdminFlags () |
| Gets the full administration flags for the currently logged in user. | |
| int | getPermissions () |
| Gets the permissions for the currently logged in user. | |
| boolean | havePermission (int functions) |
| Checks if the current user has all of the given permissions. | |
| boolean | havePermission (int mask, boolean all) |
| Checks if the current user has any or all of the given permissions. | |
| String | getClientConfig () |
| Gets the client configuration string. | |
| void | setDebug (boolean on) |
| Enables/disables runtime debug output. | |
| OptionHolder | getLoginOptions () |
| Gets the current login options. | |
| String | getRemoteIp () |
| The IP number of this client, as seen by the server. | |
A session to the MGP Server.
When connected to the server it can be used to send and receive operations using MGP (Messaging Gateway Protocol). It provides a way to get information about the server as well as to send and receive messages.
| void com::nmt::mgp::MgpSessionI::close | ( | ) | throws MgpException |
Clears the session by logging off from the server and closing the current connection.
Implemented in com::nmt::mgp::MgpSession.
| void com::nmt::mgp::MgpSessionI::connect | ( | String | host, | |
| int | port, | |||
| boolean | useSsl | |||
| ) | throws MgpException |
Connect to the server.
| host | the host name to connect to | |
| port | the port number to connect to | |
| useSsl | true if and only if the communication should use SSL |
| MgpException | if a communication error occurs |
Implemented in com::nmt::mgp::MgpSession.
| java.sql.ResultSet com::nmt::mgp::MgpSessionI::dbexec | ( | String | profile, | |
| String | sql | |||
| ) | throws MgpException, java.sql.SQLException |
Send an SQL string to be executed on the EMG server.
| profile | the database profile name | |
| sql | the SQL string |
INSERT or UPDATE). Implemented in com::nmt::mgp::MgpSession.
| void com::nmt::mgp::MgpSessionI::deleteMessage | ( | int | id | ) | throws MgpException |
Delete a message.
Shortcut for deleting the message identified by the specified id.
Returns message status on success, otherwise an MgpException is thrown.
| id | the unique identifier of the message, returned by sendMessage(Message) |
| MgpException | if the message isn't found on the server, or a communication error occurs |
Implemented in com::nmt::mgp::MgpSession.
| OptionHolder com::nmt::mgp::MgpSessionI::execute | ( | int | operation, | |
| OptionHolder | options | |||
| ) | throws MgpException |
Send an operation with arguments to the EMG server, and wait for the response.
The implementation of this method should be synchronized to provide a simple multithread safe access point.
| operation | the operation number, as one of MGP_OP_* from Mgp | |
| options | the input parameters, to be sent to the server |
| MgpException | if a communication error occurs |
Implemented in com::nmt::mgp::MgpSession.
| int com::nmt::mgp::MgpSessionI::getAdminFlags | ( | ) |
Gets the full administration flags for the currently logged in user.
Implemented in com::nmt::mgp::MgpSession.
| String com::nmt::mgp::MgpSessionI::getClientConfig | ( | ) |
Gets the client configuration string.
Implemented in com::nmt::mgp::MgpSession.
| OptionHolder com::nmt::mgp::MgpSessionI::getLoginOptions | ( | ) |
Gets the current login options.
Implemented in com::nmt::mgp::MgpSession.
| int com::nmt::mgp::MgpSessionI::getPermissions | ( | ) |
Gets the permissions for the currently logged in user.
The value is a combined bitmask of MGP_ACCESS_* from Mgp.
Implemented in com::nmt::mgp::MgpSession.
| String com::nmt::mgp::MgpSessionI::getRemoteIp | ( | ) |
The IP number of this client, as seen by the server.
Implemented in com::nmt::mgp::MgpSession.
| boolean com::nmt::mgp::MgpSessionI::havePermission | ( | int | functions | ) |
Checks if the current user has all of the given permissions.
Implemented in com::nmt::mgp::MgpSession.
| boolean com::nmt::mgp::MgpSessionI::havePermission | ( | int | mask, | |
| boolean | all | |||
| ) |
Checks if the current user has any or all of the given permissions.
The permissions should be from the MGP_ACCESS_* constants in Mgp.
| mask | the bitmask of permissions | |
| all | true if all permissions must be present |
Implemented in com::nmt::mgp::MgpSession.
| boolean com::nmt::mgp::MgpSessionI::isAdmin | ( | ) |
Returns whether user in session is an administrator.
Implemented in com::nmt::mgp::MgpSession.
| void com::nmt::mgp::MgpSessionI::login | ( | String | username, | |
| String | password, | |||
| String | servicetype | |||
| ) | throws MgpException |
Login to the server using username and password for authentication.
| username | the EMG username, sent as Mgp#MGP_OPTION_USERNAME | |
| password | the EMG password, sent as Mgp#MGP_OPTION_PASSWORD | |
| servicetype | the systemtype, sent as Mgp#MGP_OPTION_SYSTEMTYPE |
| MgpException | if a communication error occurs |
Implemented in com::nmt::mgp::MgpSession.
| void com::nmt::mgp::MgpSessionI::login | ( | String | username, | |
| String | password | |||
| ) | throws MgpException |
Login to the server using username and password for authentication.
Implemented in com::nmt::mgp::MgpSession.
| void com::nmt::mgp::MgpSessionI::logoff | ( | ) | throws MgpException |
Logoff from the server.
Implemented in com::nmt::mgp::MgpSession.
| int com::nmt::mgp::MgpSessionI::queryMessage | ( | int | id | ) | throws MgpException |
Query the server for status of a message, identified by the specified id.
Returns message status on success, otherwise an MgpException is thrown.
| id | the unique identifier of the message, returned by sendMessage(Message) |
| MgpException | if the message isn't found on the server, or a communication error occurs |
Implemented in com::nmt::mgp::MgpSession.
| int com::nmt::mgp::MgpSessionI::readOperation | ( | OptionHolder | options | ) | throws MgpException |
Read an operation request from the server and store the options in the provided option holder.
| options | an empty OptionHolder, which will get filled with the parameters to the operation |
| MgpException | if a communication error occurs |
Implemented in com::nmt::mgp::MgpSession.
| int com::nmt::mgp::MgpSessionI::readResponse | ( | ) | throws MgpException |
Read the response to the last command sent to the EMG server.
Calls readOperation(OptionHolder), extracts the return code (Mgp.MGP_OPTION_RETCODE) and returns the value as an int.
| MgpException | if an error occurs when reading from the stream |
Implemented in com::nmt::mgp::MgpSession.
| void com::nmt::mgp::MgpSessionI::reload | ( | ) | throws MgpException |
Reload the configuration on the server, while keeping the connection open.
Implemented in com::nmt::mgp::MgpSession.
| int com::nmt::mgp::MgpSessionI::sendMessage | ( | Message | msg | ) | throws MgpException |
Send a message.
Destination address and message data is mandatory. This is checked before the message is sent. If the message is not valid an exception is thrown.
Returns the message id on success, otherwise an MgpException is thrown.
| msg | A message with message text, destination address etc set |
| MgpException | if a communication error occurs |
Implemented in com::nmt::mgp::MgpSession.
| void com::nmt::mgp::MgpSessionI::sendOperation | ( | int | operation, | |
| OptionHolder | options, | |||
| boolean | doFlush | |||
| ) | throws MgpException |
Send an operation to the EMG server.
| operation | the operation number, one of Mgp.MGP_OP_* | |
| options | the list of operation parameters | |
| doFlush | true if and only if the socket stream should be flushed after the operation |
Implemented in com::nmt::mgp::MgpSession.
| void com::nmt::mgp::MgpSessionI::sendOperation | ( | int | operation, | |
| OptionHolder | options | |||
| ) | throws MgpException |
Send an operation to the EMG server.
This is a simple overload to sendOperation(int,OptionHolder,boolean), with true used as the third argument.
| operation | the operation number, one of Mgp.MGP_OP_* | |
| options | the list of operation parameters |
Implemented in com::nmt::mgp::MgpSession.
| void com::nmt::mgp::MgpSessionI::setDebug | ( | boolean | on | ) |
Enables/disables runtime debug output.
| on | true for debug out, false if not |
Implemented in com::nmt::mgp::MgpSession.
1.7.1