JML

net.sf.jml.message.p2p
Class MsnP2PMessage

java.lang.Object
  extended by net.sf.jml.message.MsnMimeMessage
      extended by net.sf.jml.message.p2p.MsnP2PMessage
Direct Known Subclasses:
MsnP2PAckMessage, MsnP2PByeAckMessage, MsnP2PDataMessage, MsnP2PPreperationMessage, MsnP2PSlpMessage

public abstract class MsnP2PMessage
extends MsnMimeMessage

Msn P2P message. have a binary header. See: http://zoronax.bot2k3.net/msn6/msnp9/msnslp_p2p.html and http://siebe.bot2k3.net/docs/?url=binheaders.html.

Author:
Roger Chen, Angel Barragán Chacón

Field Summary
protected static int BINARY_FOOTER_LEN
          Binary footer length
protected static int BINARY_HEADER_LEN
          Length of the binary header for the P2P messages.
protected static int FLAG_ACK
           
protected static int FLAG_BYE
           
protected static int FLAG_BYE_ACK
           
protected static int FLAG_DATA
           
protected static int FLAG_NONE
           
protected static String KEY_P2P_DEST
          P2P message destination header name.
 
Fields inherited from class net.sf.jml.message.MsnMimeMessage
headers
 
Constructor Summary
MsnP2PMessage()
          Creates a new P2P message.
 
Method Summary
protected abstract  byte[] bodyToMessage()
          Retrieve the body part for this P2P message.
 int getAppId()
          Retrieves the application identifier for this P2P message.
 int getCurrentLength()
          Retrieves the current length of this message.
 int getField7()
          Retrieves the Acknowledged identifier for this P2P message.
 int getField8()
          Retrieves the Acknowledged unique ID for this message.
 long getField9()
          Retrieves the Acknowledged data size for this P2P message.
 int getFlag()
          Retrieves the flag value for this P2P message.
 int getIdentifier()
          Retrieves the message identifier for this P2P message.
 long getOffset()
          Retrieves the data offset in this P2P message.
 String getP2PDest()
          Retrieve the P2P destination header value.
 int getSessionId()
          Retrieves the session identifier for this P2P message.
 long getTotalLength()
          Retrieves the total length of the data (MsnObject) to be transmited.
protected  void messageReceived(MsnSession session, MsnContact contact)
          The message have received, invoked by dispatch thread
protected  void parseMessage(byte[] message)
          Parse content from IncomingMSG's chunk data.
protected abstract  void parseP2PBody(ByteBuffer buffer)
          Parse the body part of this P2P message.
 void setAppId(int appId)
          Sets the application identifier for this P2P message.
 void setCurrentLength(int currentLength)
          Sets the current length for this message.
 void setField7(int field7)
          Sets the Acknowledged identifier for this message.
 void setField8(int field8)
          Sets the Acknowledged unique ID for this message.
 void setField9(long field9)
          Sets the Acknowledged data size for this P2P message.
 void setFlag(int flag)
          Sets the new flag value for this P2P message.
 void setIdentifier(int identifier)
          Sets the new message identifier for this P2P message.
 void setOffset(long offset)
          Sets the offset of the transmited data for this P2P message.
 void setP2PDest(String dest)
          Sets the destination for this P2P message.
 void setSessionId(int sessionId)
          Sets the session identifier for this P2P message.
 void setTotalLength(long totalLength)
          Sets the total amount of data to be transmited.
protected  String toDebugBody()
          Retrieves a String representation of the body for this message.
 String toDebugString()
          Creates a debug representation for this P2P message.
 OutgoingMSG[] toOutgoingMsg(MsnProtocol protocol)
          Generate OutgoingMSGs.
 
Methods inherited from class net.sf.jml.message.MsnMimeMessage
getCharset, getContentType, getHeaders, getMimeVersion, parseBuffer, setContentType, setMimeVersion, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

KEY_P2P_DEST

protected static final String KEY_P2P_DEST
P2P message destination header name.

See Also:
Constant Field Values

BINARY_HEADER_LEN

protected static final int BINARY_HEADER_LEN
Length of the binary header for the P2P messages.

See Also:
Constant Field Values

FLAG_NONE

protected static final int FLAG_NONE
See Also:
Constant Field Values

FLAG_ACK

protected static final int FLAG_ACK
See Also:
Constant Field Values

FLAG_BYE_ACK

protected static final int FLAG_BYE_ACK
See Also:
Constant Field Values

FLAG_DATA

protected static final int FLAG_DATA
See Also:
Constant Field Values

FLAG_BYE

protected static final int FLAG_BYE
See Also:
Constant Field Values

BINARY_FOOTER_LEN

protected static final int BINARY_FOOTER_LEN
Binary footer length

See Also:
Constant Field Values
Constructor Detail

MsnP2PMessage

public MsnP2PMessage()
Creates a new P2P message.

Method Detail

parseMessage

protected void parseMessage(byte[] message)
Description copied from class: MsnMimeMessage
Parse content from IncomingMSG's chunk data.

Overrides:
parseMessage in class MsnMimeMessage
Parameters:
message - IncomingMSG's chunk data

toOutgoingMsg

public OutgoingMSG[] toOutgoingMsg(MsnProtocol protocol)
Description copied from class: MsnMimeMessage
Generate OutgoingMSGs.

Overrides:
toOutgoingMsg in class MsnMimeMessage
Parameters:
protocol - used MsnProtocol
Returns:
generated OutgoingMSGs. A MsnMimeMessage may generate multi OutgoingMSGs.
See Also:
MsnMimeMessage.toOutgoingMsg(MsnProtocol)

messageReceived

protected void messageReceived(MsnSession session,
                               MsnContact contact)
Description copied from class: MsnMimeMessage
The message have received, invoked by dispatch thread

Overrides:
messageReceived in class MsnMimeMessage
Parameters:
session - the MsnSession which received the message
contact - the user who sent this message

parseP2PBody

protected abstract void parseP2PBody(ByteBuffer buffer)
Parse the body part of this P2P message.

Parameters:
buffer - Buffer with the body to be parsed.

bodyToMessage

protected abstract byte[] bodyToMessage()
Retrieve the body part for this P2P message.

Returns:
Binary content for the body part of this P2P message.

toDebugString

public String toDebugString()
Creates a debug representation for this P2P message.

Returns:
String representation for the message.

toDebugBody

protected String toDebugBody()
Retrieves a String representation of the body for this message.

Returns:
String value.

getP2PDest

public String getP2PDest()
Retrieve the P2P destination header value.

Returns:
Value for the destination of this P2P message.

setP2PDest

public void setP2PDest(String dest)
Sets the destination for this P2P message.

Parameters:
dest - New destination for this P2P message.

getSessionId

public int getSessionId()
Retrieves the session identifier for this P2P message.

Returns:
Session identifier.

setSessionId

public void setSessionId(int sessionId)
Sets the session identifier for this P2P message.

Parameters:
sessionId - New session identifier.

getIdentifier

public int getIdentifier()
Retrieves the message identifier for this P2P message.

Returns:
Message identifier.

setIdentifier

public void setIdentifier(int identifier)
Sets the new message identifier for this P2P message.

Parameters:
identifier - New message identifier.

getOffset

public long getOffset()
Retrieves the data offset in this P2P message.

Returns:
data offset. If this is a data message, this fiel has the offset of the sending data with respect to the total data.

setOffset

public void setOffset(long offset)
Sets the offset of the transmited data for this P2P message.

Parameters:
offset - New offset for the message.

getTotalLength

public long getTotalLength()
Retrieves the total length of the data (MsnObject) to be transmited.

Returns:
Total amount of bytes to be transmited for the MsnObject.

setTotalLength

public void setTotalLength(long totalLength)
Sets the total amount of data to be transmited.

Parameters:
totalLength - New total amount of data to be transmited for the MsnObject.

getCurrentLength

public int getCurrentLength()
Retrieves the current length of this message.

Returns:
Current length for this message.

setCurrentLength

public void setCurrentLength(int currentLength)
Sets the current length for this message.

Parameters:
currentLength - New current length for this message.

getFlag

public int getFlag()
Retrieves the flag value for this P2P message.

Returns:
Type of message.

setFlag

public void setFlag(int flag)
Sets the new flag value for this P2P message.

Parameters:
flag - Type of message.

getField7

public int getField7()
Retrieves the Acknowledged identifier for this P2P message.

Returns:
the identifier.

setField7

public void setField7(int field7)
Sets the Acknowledged identifier for this message.

Parameters:
field7 - The identifier.

getField8

public int getField8()
Retrieves the Acknowledged unique ID for this message.

Returns:
the identifier.

setField8

public void setField8(int field8)
Sets the Acknowledged unique ID for this message.

Parameters:
field8 - The identifier.

getField9

public long getField9()
Retrieves the Acknowledged data size for this P2P message.

Returns:
The data size.

setField9

public void setField9(long field9)
Sets the Acknowledged data size for this P2P message.

Parameters:
field9 - The size.

getAppId

public int getAppId()
Retrieves the application identifier for this P2P message.

Returns:
Identifier.

setAppId

public void setAppId(int appId)
Sets the application identifier for this P2P message.

Parameters:
appId - New application identifier.

JML