org.livetribe.slp.spi.msg
Class Message

java.lang.Object
  extended by org.livetribe.slp.spi.msg.BytesBlock
      extended by org.livetribe.slp.spi.msg.Message
Direct Known Subclasses:
Rply, Rqst, SrvAck, SrvDeReg, SrvReg

public abstract class Message
extends BytesBlock

The RFC 2608 message header is the following:

  0                   1                   2                   3
  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 |    Version    |  Function-ID  |            Length             |
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 | Length, contd.|O|F|R|       reserved          |Next Ext Offset|
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 |  Next Extension Offset, contd.|              XID              |
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 |      Language Tag Length      |         Language Tag          \
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 
The RFC 2608 extension is the following:
  0                   1                   2                   3
  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 |         Extension ID          |       Next Extension Offset   |
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 | Offset, contd.|                Extension Data                 \
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 

Version:
$Rev: 159 $ $Date: 2006-06-06 22:17:40 +0200 (Tue, 06 Jun 2006) $

Field Summary
static byte ATTR_RPLY_TYPE
           
static byte ATTR_RQST_TYPE
           
static byte DA_ADVERT_TYPE
           
static byte SA_ADVERT_TYPE
           
static byte SRV_ACK_TYPE
           
static byte SRV_DEREG_TYPE
           
static byte SRV_REG_TYPE
           
static byte SRV_RPLY_TYPE
           
static byte SRV_RQST_TYPE
           
static byte SRV_TYPE_RPLY_TYPE
           
static byte SRV_TYPE_RQST_TYPE
           
 
Fields inherited from class org.livetribe.slp.spi.msg.BytesBlock
EMPTY_BYTES, EMPTY_STRINGS
 
Constructor Summary
Message()
           
 
Method Summary
 void addExtension(Extension extension)
           
protected static byte[] attributesToBytes(Attributes attributes)
           
static Message deserialize(byte[] bytes)
          Parses the header of SLP messages, then each message parses its body via deserializeBody(byte[]).
protected abstract  void deserializeBody(byte[] bytes)
           
protected  void deserializeExtensions(byte[] bytes, int firstExtensionOffset)
           
 Collection getExtensions()
           
 String getLanguage()
           
abstract  byte getMessageType()
           
 int getXID()
           
 boolean isFresh()
           
 boolean isMulticast()
           
 boolean isOverflow()
           
protected static byte[] scopesToBytes(Scopes scopes)
           
 byte[] serialize()
           
protected abstract  byte[] serializeBody()
           
protected  byte[] serializeExtensions(int firstExtensionOffset)
           
protected static byte[] serviceTypeToBytes(ServiceType serviceType)
           
 void setFresh(boolean fresh)
           
 void setLanguage(String language)
           
 void setMulticast(boolean multicast)
           
 void setOverflow(boolean overflow)
           
 void setXID(int xid)
           
 
Methods inherited from class org.livetribe.slp.spi.msg.BytesBlock
escape, readInt, readString, readStringArray, stringToUTF8Bytes, unescape, utf8BytesToString, writeInt, writeString, writeStringArray
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SRV_RQST_TYPE

public static final byte SRV_RQST_TYPE
See Also:
Constant Field Values

SRV_RPLY_TYPE

public static final byte SRV_RPLY_TYPE
See Also:
Constant Field Values

SRV_REG_TYPE

public static final byte SRV_REG_TYPE
See Also:
Constant Field Values

SRV_DEREG_TYPE

public static final byte SRV_DEREG_TYPE
See Also:
Constant Field Values

SRV_ACK_TYPE

public static final byte SRV_ACK_TYPE
See Also:
Constant Field Values

ATTR_RQST_TYPE

public static final byte ATTR_RQST_TYPE
See Also:
Constant Field Values

ATTR_RPLY_TYPE

public static final byte ATTR_RPLY_TYPE
See Also:
Constant Field Values

DA_ADVERT_TYPE

public static final byte DA_ADVERT_TYPE
See Also:
Constant Field Values

SRV_TYPE_RQST_TYPE

public static final byte SRV_TYPE_RQST_TYPE
See Also:
Constant Field Values

SRV_TYPE_RPLY_TYPE

public static final byte SRV_TYPE_RPLY_TYPE
See Also:
Constant Field Values

SA_ADVERT_TYPE

public static final byte SA_ADVERT_TYPE
See Also:
Constant Field Values
Constructor Detail

Message

public Message()
Method Detail

serializeBody

protected abstract byte[] serializeBody()
                                 throws ServiceLocationException
Throws:
ServiceLocationException

deserializeBody

protected abstract void deserializeBody(byte[] bytes)
                                 throws ServiceLocationException
Throws:
ServiceLocationException

serializeExtensions

protected byte[] serializeExtensions(int firstExtensionOffset)
                              throws ServiceLocationException
Throws:
ServiceLocationException

deserializeExtensions

protected void deserializeExtensions(byte[] bytes,
                                     int firstExtensionOffset)
                              throws ServiceLocationException
Throws:
ServiceLocationException

addExtension

public void addExtension(Extension extension)

getExtensions

public Collection getExtensions()

getMessageType

public abstract byte getMessageType()

isMulticast

public boolean isMulticast()

setMulticast

public void setMulticast(boolean multicast)

isOverflow

public boolean isOverflow()

setOverflow

public void setOverflow(boolean overflow)

isFresh

public boolean isFresh()

setFresh

public void setFresh(boolean fresh)

getXID

public int getXID()

setXID

public void setXID(int xid)

getLanguage

public String getLanguage()

setLanguage

public void setLanguage(String language)

serialize

public byte[] serialize()
                 throws ServiceLocationException
Throws:
ServiceLocationException

deserialize

public static Message deserialize(byte[] bytes)
                           throws ServiceLocationException
Parses the header of SLP messages, then each message parses its body via deserializeBody(byte[]).

Throws:
ServiceLocationException - If the bytes cannot be parsed

attributesToBytes

protected static byte[] attributesToBytes(Attributes attributes)
                                   throws ServiceLocationException
Throws:
ServiceLocationException

scopesToBytes

protected static byte[] scopesToBytes(Scopes scopes)
                               throws ServiceLocationException
Throws:
ServiceLocationException

serviceTypeToBytes

protected static byte[] serviceTypeToBytes(ServiceType serviceType)
                                    throws ServiceLocationException
Throws:
ServiceLocationException


Copyright © 2006-2012 LiveTribe. All Rights Reserved.