net.spy.net
Class SNPP

java.lang.Object
  extended by net.spy.SpyObject
      extended by net.spy.net.SNPP

public class SNPP
extends SpyObject

SNPP client.


Field Summary
static int ADMIN_FAILURE
          Response code indicating a command failed (invalid pager ID, illegal parameter, etc...).
static int COMMAND_NOT_IMPLEMENTED
          Response code indicating that a command was issued that was not implemented.
static int DATA_OK
          Response code indicating DATA command was accepted and input should begin.
static int DUPLICATE_COMMAND_ENTRY
          Response code indicating a command was implemented in duplicate.
static int FATAL_ERROR
          Response code indicating a fatal error which will be followed by a terminated connection.
static int MAX_ENTRIES_EXCEEDED
          Response code indicating too many of something was entered (i.e.
static int MSG_AWAITING_ACK
          Response code indicating a message was delivered and is awaiting a reply ACK.
static int MSG_AWAITING_REPLY
          Response code indicating a message was delivered and is awaiting a reply.
static int MSG_DELIVERED
          Response code indicating a message has been delivered.
static int MSG_QUEUED
          Response code indicating a message was queued for delivery.
static int MTYPE_DATA_SUCCESS
          Message type indicating DATA was accepted and server is ready for input.
static int MTYPE_PERM_FAILURE
          Message type indicating a permanent failure.
static int MTYPE_SUCCESS
          Message type indicating success.
static int MTYPE_SUCCESS_2WAY
          Message type indicating a successful two-way transaction.
static int MTYPE_SUCCESS_QUEUED
          Successful queued transaction.
static int MTYPE_TEMP_FAILURE
          Message type indicating a temporary failure.
static int MTYPE_UNSUCCESSFUL_2WAY
          Message type indicating an unsuccesful two-way specific transaction.
static int MULTILINE_HELP
          Response code indicating a line of multiline help.
static int OK
          Response code inicating a successful transaction.
static int QUIT_ACK
          Response code to acknowldege a quit command.
static int RESPONSE
          Response code indicating a response to a message is available.
static int SINGLELINE_HELP
          Response code indicating single line help.
static int SNPP_PORT
          SNPP default port.
static int SYSTEM_FAILURE
          Response code indicating a command failed (system problem).
 
Constructor Summary
SNPP(java.lang.String host, int port)
          Get a new SNPP object connected to host:port
SNPP(java.lang.String host, int port, int timeout)
          Get a new SNPP object connected to host:port
 
Method Summary
 void addResponse(java.lang.String response)
          adds a response to the SNPP message.
 void close()
          Close the connection to the SNPP server.
 void cmd(java.lang.String command)
          Send an SNPP command.
 void data(java.lang.String msg)
          sets the message to send, keeps newlines and all that
protected  void finalize()
           
 java.lang.String getCurrentline()
          Current full line received from the SNPP server.
 java.lang.String getCurrentmessage()
          Current message received from the SNPP server.
 int getCurrentStatus()
          Current status received from SNPP server.
 int getCurrentStatusType()
          Current status type received from SNPP server.
 java.lang.String getResponse()
          Check for a response from a 2way message.
 java.lang.String getResponse(java.lang.String tag)
          Check for a response from a 2way message.
 java.lang.String getTag()
          gets the message tag on a 2way page
 void message(java.lang.String msg)
          sets the message to send
 void pagerID(java.lang.String id)
          sets the pager ID
 void send()
          send is handled separately in case it's a two-way transaction.
 void sendpage(java.lang.String id, java.lang.String msg)
          Send a simple page.
 void twoWay()
          Put this into 2way mode.
 
Methods inherited from class net.spy.SpyObject
getLogger
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SNPP_PORT

public static final int SNPP_PORT
SNPP default port.

See Also:
Constant Field Values

MULTILINE_HELP

public static final int MULTILINE_HELP
Response code indicating a line of multiline help.

See Also:
Constant Field Values

SINGLELINE_HELP

public static final int SINGLELINE_HELP
Response code indicating single line help.

See Also:
Constant Field Values

QUIT_ACK

public static final int QUIT_ACK
Response code to acknowldege a quit command.

See Also:
Constant Field Values

OK

public static final int OK
Response code inicating a successful transaction.

See Also:
Constant Field Values

FATAL_ERROR

public static final int FATAL_ERROR
Response code indicating a fatal error which will be followed by a terminated connection.

See Also:
Constant Field Values

COMMAND_NOT_IMPLEMENTED

public static final int COMMAND_NOT_IMPLEMENTED
Response code indicating that a command was issued that was not implemented.

See Also:
Constant Field Values

DUPLICATE_COMMAND_ENTRY

public static final int DUPLICATE_COMMAND_ENTRY
Response code indicating a command was implemented in duplicate.

See Also:
Constant Field Values

ADMIN_FAILURE

public static final int ADMIN_FAILURE
Response code indicating a command failed (invalid pager ID, illegal parameter, etc...).

See Also:
Constant Field Values

SYSTEM_FAILURE

public static final int SYSTEM_FAILURE
Response code indicating a command failed (system problem).

See Also:
Constant Field Values

MAX_ENTRIES_EXCEEDED

public static final int MAX_ENTRIES_EXCEEDED
Response code indicating too many of something was entered (i.e. too many pager IDs).

See Also:
Constant Field Values

DATA_OK

public static final int DATA_OK
Response code indicating DATA command was accepted and input should begin.

See Also:
Constant Field Values

MSG_AWAITING_ACK

public static final int MSG_AWAITING_ACK
Response code indicating a message was delivered and is awaiting a reply ACK.

See Also:
Constant Field Values

MSG_AWAITING_REPLY

public static final int MSG_AWAITING_REPLY
Response code indicating a message was delivered and is awaiting a reply.

See Also:
Constant Field Values

MSG_DELIVERED

public static final int MSG_DELIVERED
Response code indicating a message has been delivered.

See Also:
Constant Field Values

RESPONSE

public static final int RESPONSE
Response code indicating a response to a message is available.

See Also:
Constant Field Values

MSG_QUEUED

public static final int MSG_QUEUED
Response code indicating a message was queued for delivery.

See Also:
Constant Field Values

MTYPE_SUCCESS

public static final int MTYPE_SUCCESS
Message type indicating success.

See Also:
Constant Field Values

MTYPE_DATA_SUCCESS

public static final int MTYPE_DATA_SUCCESS
Message type indicating DATA was accepted and server is ready for input.

See Also:
Constant Field Values

MTYPE_PERM_FAILURE

public static final int MTYPE_PERM_FAILURE
Message type indicating a permanent failure.

See Also:
Constant Field Values

MTYPE_TEMP_FAILURE

public static final int MTYPE_TEMP_FAILURE
Message type indicating a temporary failure.

See Also:
Constant Field Values

MTYPE_UNSUCCESSFUL_2WAY

public static final int MTYPE_UNSUCCESSFUL_2WAY
Message type indicating an unsuccesful two-way specific transaction.

See Also:
Constant Field Values

MTYPE_SUCCESS_2WAY

public static final int MTYPE_SUCCESS_2WAY
Message type indicating a successful two-way transaction.

See Also:
Constant Field Values

MTYPE_SUCCESS_QUEUED

public static final int MTYPE_SUCCESS_QUEUED
Successful queued transaction.

See Also:
Constant Field Values
Constructor Detail

SNPP

public SNPP(java.lang.String host,
            int port,
            int timeout)
     throws java.io.IOException,
            java.net.UnknownHostException
Get a new SNPP object connected to host:port

Parameters:
host - SNPP host to connect to
port - SNPP port number
timeout - SO_TIMEOUT in milliseconds
Throws:
java.io.IOException - Thrown if the various input and output streams cannot be established.
java.net.UnknownHostException - Thrown if the SNPP server hostname cannot be resolved.

SNPP

public SNPP(java.lang.String host,
            int port)
     throws java.io.IOException,
            java.net.UnknownHostException
Get a new SNPP object connected to host:port

Parameters:
host - SNPP host to connect to
port - SNPP port number
Throws:
java.io.IOException - Thrown if the various input and output streams cannot be established.
java.net.UnknownHostException - Thrown if the SNPP server hostname cannot be resolved.
Method Detail

getCurrentline

public java.lang.String getCurrentline()
Current full line received from the SNPP server.


getCurrentmessage

public java.lang.String getCurrentmessage()
Current message received from the SNPP server.


getCurrentStatus

public int getCurrentStatus()
Current status received from SNPP server.


getCurrentStatusType

public int getCurrentStatusType()
Current status type received from SNPP server.


twoWay

public void twoWay()
            throws java.lang.Exception
Put this into 2way mode.

Throws:
java.lang.Exception - when the 2way command fails

pagerID

public void pagerID(java.lang.String id)
             throws java.lang.Exception
sets the pager ID

Parameters:
id - snpp pager id
Throws:
java.lang.Exception - when the page command fails

message

public void message(java.lang.String msg)
             throws java.lang.Exception
sets the message to send

Parameters:
msg - snpp message
Throws:
java.lang.Exception - when the command fails

data

public void data(java.lang.String msg)
          throws java.lang.Exception
sets the message to send, keeps newlines and all that

Parameters:
msg - snpp message
Throws:
java.lang.Exception - when the command fails, possibly because DATA is not supported

getTag

public java.lang.String getTag()
gets the message tag on a 2way page

Returns:
the tag, or null if there is no tag

sendpage

public void sendpage(java.lang.String id,
                     java.lang.String msg)
              throws java.lang.Exception
Send a simple page.

Parameters:
id - SNPP recipient ID.
msg - msg to send.
Throws:
java.lang.Exception - Thrown if any of the commands required to send the page threw an exception.

send

public void send()
          throws java.lang.Exception
send is handled separately in case it's a two-way transaction.

Throws:
java.lang.Exception - Thrown if the send command fails.

getResponse

public java.lang.String getResponse(java.lang.String tag)
                             throws java.lang.Exception
Check for a response from a 2way message.

Parameters:
tag - the message tag to look up.
Returns:
the response message, or NULL if it's not ready
Throws:
java.lang.Exception - when the msta command fails, or we're not doing 2way.

getResponse

public java.lang.String getResponse()
                             throws java.lang.Exception
Check for a response from a 2way message.

Returns:
the response message, or NULL if it's not ready
Throws:
java.lang.Exception - when the msta command fails, or we're not doing 2way.

addResponse

public void addResponse(java.lang.String response)
                 throws java.lang.Exception
adds a response to the SNPP message.

Parameters:
response - the canned response to add
Throws:
java.lang.Exception - when we're not in a 2way transaction, or the command fails.

cmd

public void cmd(java.lang.String command)
         throws java.lang.Exception
Send an SNPP command.

Parameters:
command - command to send. It's sent literally to the SNPP server.
Throws:
java.lang.Exception - Thrown if the command does not return an ``OK'' status from the SNPP server.

close

public void close()
Close the connection to the SNPP server.


finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable


Copyright © 1995-2007 SPY Internetworking. All Rights Reserved.