context.arch.comm.protocol
Class HTTPMulticastUDPSocket

java.lang.Object
  extended bycontext.arch.comm.protocol.MulticastUDPSocket
      extended bycontext.arch.comm.protocol.HTTPMulticastUDPSocket
All Implemented Interfaces:
java.lang.Cloneable, CommunicationsMulticast, MulticastConstants, java.lang.Runnable

public class HTTPMulticastUDPSocket
extends MulticastUDPSocket
implements CommunicationsMulticast

This object is able to connect to a multicast group and to send multicast messages

Author:
Agathe

Field Summary
static boolean DEBUG
          Debug flag.
static java.lang.String GET
          HTTP GET request type
static java.lang.String POST
          HTTP POST request type
static java.lang.String PROTOCOL
          The protocol being used is HTTP
 
Fields inherited from interface context.arch.comm.protocol.MulticastConstants
DEFAULT_MULTICAST_ADDRESS, DEFAULT_MULTICAST_PORT, TTL_CONTINENT, TTL_COUNTRY, TTL_COUNTY, TTL_LOCAL_NETWORK, TTL_SITE, TTL_TRANSMITTER, TTL_WORLDWIDE
 
Constructor Summary
HTTPMulticastUDPSocket(CommunicationsObject object)
          Basic constructor for HTTPMulticastSocket that calls MulticastUDPSocket
 
Method Summary
 java.lang.String addProtocol(java.lang.String data, java.lang.String url)
          This method adds the HTTP protocol for a POST request (POST is the default)
 java.lang.String addProtocol(java.lang.String data, java.lang.String url, java.lang.String type)
          This abstract method adds the protocol to a request to be sent
 java.lang.String getProtocol()
          Abstract method to get the communications protocol being used
 void handleIncomingRequest(java.net.DatagramPacket packet)
          Stub method that handles incoming HTTP multicast packets.
 void quit()
          Abstract method to call when stopping a CommunicationsServer object
 void sendMessage(java.lang.String message)
          This abstract method sends a request
 RequestData stripProtocol(java.net.DatagramPacket packet)
          This abstract method strips the protocol away from the received request
 
Methods inherited from class context.arch.comm.protocol.MulticastUDPSocket
getMulticastGroup, getMulticastPort, getTTL, run, sendPacket, setTTL, start, stopServer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface context.arch.comm.CommunicationsMulticast
start
 

Field Detail

DEBUG

public static boolean DEBUG
Debug flag. Set to true to see debug messages.


PROTOCOL

public static final java.lang.String PROTOCOL
The protocol being used is HTTP

See Also:
Constant Field Values

GET

public static final java.lang.String GET
HTTP GET request type

See Also:
Constant Field Values

POST

public static final java.lang.String POST
HTTP POST request type

See Also:
Constant Field Values
Constructor Detail

HTTPMulticastUDPSocket

public HTTPMulticastUDPSocket(CommunicationsObject object)
Basic constructor for HTTPMulticastSocket that calls MulticastUDPSocket

Parameters:
object - Handle of the generic instantiating communications object
See Also:
MulticastUDPSocket
Method Detail

handleIncomingRequest

public void handleIncomingRequest(java.net.DatagramPacket packet)
Stub method that handles incoming HTTP multicast packets. It calls the equivalent method in the CommunicationsObject and then closes the socket.

Specified by:
handleIncomingRequest in interface CommunicationsMulticast
Overrides:
handleIncomingRequest in class MulticastUDPSocket
Parameters:
packet - DatagramPacket to receive HTTP data in
See Also:
CommunicationsObject.handleIncomingRequest(java.net.DatagramPacket)

quit

public void quit()
Abstract method to call when stopping a CommunicationsServer object

Specified by:
quit in interface CommunicationsMulticast

getProtocol

public java.lang.String getProtocol()
Abstract method to get the communications protocol being used

Specified by:
getProtocol in interface CommunicationsMulticast
Returns:
the protocol being used

stripProtocol

public RequestData stripProtocol(java.net.DatagramPacket packet)
                          throws ProtocolException
This abstract method strips the protocol away from the received request

Specified by:
stripProtocol in interface CommunicationsMulticast
Parameters:
packet - The datagram packet the message is being received in
Returns:
the request with the protocol stripped away
Throws:
ProtocolException - thrown if protocol can't be stripped away
See Also:
#addReplyProtocol(String), CommunicationsClient#addRequestProtocol(String,String), CommunicationsClient#stripReplyProtocol(java.net.Socket)

addProtocol

public java.lang.String addProtocol(java.lang.String data,
                                    java.lang.String url)
                             throws ProtocolException
This method adds the HTTP protocol for a POST request (POST is the default)

Returns:
socket for the connection
Throws:
ProtocolException

addProtocol

public java.lang.String addProtocol(java.lang.String data,
                                    java.lang.String url,
                                    java.lang.String type)
                             throws ProtocolException
This abstract method adds the protocol to a request to be sent

Specified by:
addProtocol in interface CommunicationsMulticast
Parameters:
data - The request to add the protocol to
Returns:
the request with the protocol added
Throws:
ProtocolException - thrown if protocol can't be added
See Also:
#stripReplyProtocol(Socket), CommunicationsServer.stripRequestProtocol(Socket), CommunicationsServer.addReplyProtocol(String)

sendMessage

public void sendMessage(java.lang.String message)
This abstract method sends a request

Specified by:
sendMessage in interface CommunicationsMulticast
Parameters:
message - The message to send
Returns:
the reply to the request