EMGJavaAPI
Public Member Functions
com::nmt::mgp::MgpSessionI Interface Reference

A session to the MGP Server. More...

Inheritance diagram for com::nmt::mgp::MgpSessionI:
com::nmt::mgp::MgpSession

List of all members.

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.
String sendMessage (Message msg) throws MgpException
 Send a message.
int queryMessage (String id) throws MgpException
 Query the server for status of a message, identified by the specified id.
void deleteMessage (String id) throws MgpException
 Delete a message.
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.

Detailed Description

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.


Member Function Documentation

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.

Parameters:
hostthe host name to connect to
portthe port number to connect to
useSsltrue if and only if the communication should use SSL
Exceptions:
MgpExceptionif a communication error occurs

Implemented in com::nmt::mgp::MgpSession.

void com::nmt::mgp::MgpSessionI::deleteMessage ( String  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.

Parameters:
idthe unique identifier of the message, returned by sendMessage(Message)
Exceptions:
MgpExceptionif 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.

Parameters:
operationthe operation number, as one of MGP_OP_* from Mgp
optionsthe input parameters, to be sent to the server
Returns:
the returned parameters from the server
Exceptions:
MgpExceptionif 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.

Since:
MGP Java 1.5c

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.

Since:
MGP Java 1.4

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.

See also:
havePermission(int, boolean)

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.

Parameters:
maskthe bitmask of permissions
alltrue 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.

Deprecated:
As of MGP Java 1.4, use com.nmt.mgp.MgpSessionI#getPermissions() instead and check for the specific functionality.

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::login ( String  username,
String  password,
String  servicetype 
) throws MgpException

Login to the server using username and password for authentication.

Parameters:
usernamethe EMG username, sent as Mgp#MGP_OPTION_USERNAME
passwordthe EMG password, sent as Mgp#MGP_OPTION_PASSWORD
servicetypethe systemtype, sent as Mgp#MGP_OPTION_SYSTEMTYPE
Exceptions:
MgpExceptionif a communication error occurs

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 ( String  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.

Parameters:
idthe unique identifier of the message, returned by sendMessage(Message)
Exceptions:
MgpExceptionif 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.

Parameters:
optionsan empty OptionHolder, which will get filled with the parameters to the operation
Exceptions:
MgpExceptionif a communication error occurs
Deprecated:
Use com.nmt.mgp.MgpSessionI#execute instead.

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.

Exceptions:
MgpExceptionif an error occurs when reading from the stream
See also:
Mgp

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.

String 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.

Parameters:
msgA message with message text, destination address etc set
Exceptions:
MgpExceptionif 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.

Parameters:
operationthe operation number, one of Mgp.MGP_OP_*
optionsthe list of operation parameters
doFlushtrue if and only if the socket stream should be flushed after the operation
Deprecated:
Use com.nmt.mgp.MgpSessionI#execute instead.
See also:
Mgp

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.

Parameters:
operationthe operation number, one of Mgp.MGP_OP_*
optionsthe list of operation parameters
Deprecated:
Use com.nmt.mgp.MgpSessionI#execute instead.

Implemented in com::nmt::mgp::MgpSession.

void com::nmt::mgp::MgpSessionI::setDebug ( boolean  on)

Enables/disables runtime debug output.

Parameters:
ontrue for debug out, false if not

Implemented in com::nmt::mgp::MgpSession.


The documentation for this interface was generated from the following file: