net.spy.net
Class SNPP

java.lang.Object
  extended bynet.spy.net.SNPP

public class SNPP
extends Object

SNPP client.


Field Summary
 String currentline
          Current full line received from the SNPP server.
 String currentmessage
          Current message received from the SNPP server.
 int currentstatus
          Current status received from SNPP server.
 boolean debug
          Debug mode on/off.
 
Constructor Summary
SNPP(String host, int port)
          Get a new SNPP object connected to host:port
SNPP(String host, int port, int timeout)
          Get a new SNPP object connected to host:port
 
Method Summary
 void addResponse(String response)
          adds a response to the SNPP message.
 void close()
          Close the connection to the SNPP server.
 void cmd(String command)
          Send an SNPP command.
 void data(String msg)
          sets the message to send, keeps newlines and all that
protected  void finalize()
           
 String getResponse()
          Check for a response from a 2way message.
 String getResponse(String tag)
          Check for a response from a 2way message.
 String getTag()
          gets the message tag on a 2way page
static void main(String[] args)
          Test page routine, send pages from the commandline.
 void message(String msg)
          sets the message to send
 void pagerID(String id)
          sets the pager ID
 void send()
          send is handled separately in case it's a two-way transaction.
 void sendpage(String id, String msg)
          Send a simple page.
 void twoWay()
          Put this into 2way mode.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentline

public String currentline
Current full line received from the SNPP server.


currentmessage

public String currentmessage
Current message received from the SNPP server.


currentstatus

public int currentstatus
Current status received from SNPP server.


debug

public boolean debug
Debug mode on/off.

Constructor Detail

SNPP

public SNPP(String host,
            int port,
            int timeout)
     throws IOException,
            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:
IOException - Thrown if the various input and output streams cannot be established.
UnknownHostException - Thrown if the SNPP server hostname cannot be resolved.

SNPP

public SNPP(String host,
            int port)
     throws IOException,
            UnknownHostException
Get a new SNPP object connected to host:port

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

twoWay

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

Throws:
Exception - when the 2way command fails

pagerID

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

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

message

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

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

data

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

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

getTag

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

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

sendpage

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

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

send

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

Throws:
Exception - Thrown if the send command fails.

getResponse

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

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

getResponse

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

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

addResponse

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

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

cmd

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

Parameters:
command - command to send. It's sent literally to the SNPP server.
Throws:
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 Throwable
Throws:
Throwable

main

public static void main(String[] args)
                 throws Exception
Test page routine, send pages from the commandline.

Usage:
SNPP hostname port username password

Throws:
Exception