Diffusion .NET Classic API - Core and Common  5.9.4
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events
PushTechnology.DiffusionCore.Messaging.MessageImpl Class Referenceabstract

This is the base class for all messages. All messages have the same basic format, that being: More...

Inheritance diagram for PushTechnology.DiffusionCore.Messaging.MessageImpl:
PushTechnology.DiffusionCore.Messaging.MessageBase PushTechnology.DiffusionCore.Messaging.IMessageComparable PushTechnology.DiffusionCore.Messaging.DataMessageImpl PushTechnology.DiffusionCore.Messaging.Topic.TopicMessageImpl PushTechnology.DiffusionCore.Messaging.DeltaMessage PushTechnology.DiffusionCore.Messaging.DeltaMessageAck PushTechnology.DiffusionCore.Messaging.FetchReplyMessage PushTechnology.DiffusionCore.Messaging.Topic.TopicLoadMessage PushTechnology.DiffusionCore.Messaging.TopicLoadMessageAck PushTechnology.DiffusionCore.Messaging.CommandMessage PushTechnology.DiffusionCore.Messaging.CommandNotificationMessage PushTechnology.DiffusionCore.Messaging.CommandLoadMessage

Public Member Functions

abstract int GetMessageLength ()
 Returns the total message length including header. Note that for an encoded data message this will return the encoded message length. More...
 
abstract ByteBuffer GetBufferForWriting (ConnectionCapabilities capabilities)
 Returns the message in buffer format for writing. If the message is encoded or needs encoding then this will return the encoded version. However, if the supplied capabilities indicate that the caller can not handled the encoded version then the unencoded version would be returned. More...
 
override bool IsTopicMessage ()
 
override List< string > GetHeaders ()
 Get the headers of this message. More...
 
override string GetHeader (int index)
 Returns a header value. More...
 
override void SetHeaders (params string[] headers)
 Sets headers. One or more separate headers may be set as required. Headers may be set once and only once after constructing a message and before any data is added to the message. More...
 
override void SetHeaders (List< string > headers)
 Set the headers of this message. More...
 
override int CompareTo (IMessage message)
 Compares the current object with another object of the same type. More...
 
override int CompareTo (IMessage message, MessageComparator comparator)
 Compares this message to another message using a specified comparator. More...
 
override bool Equals (object obj)
 
override int GetHashCode ()
 
virtual bool IsDataMessage ()
 
virtual bool IsControlMessage ()
 
virtual void AddFixedHeader (string header)
 Can be used by subclasses to add an optional fixed header after creation. More...
 
void Write (ByteBuffer buffer, ConnectionCapabilities capabilities)
 Write the message to a byte buffer. More...
 
void Write (SslStream stream)
 Writes the message to a secure stream. More...
 
void Write (ClientSocket socket)
 Write the message to a socket channel. More...
 
void Write (SslStream stream, ConnectionCapabilities capabilities, bool async)
 Write the message to a secure stream. More...
 
void Write (ClientSocket socket, ConnectionCapabilities capabilities)
 Write the message to a socket channel. More...
 
- Public Member Functions inherited from PushTechnology.DiffusionCore.Messaging.MessageBase
virtual bool IsAckRequired ()
 
virtual int Size ()
 
abstract int Capacity ()
 This returns the capacity of the message. More...
 

Protected Member Functions

 MessageImpl (IExternalMessage message)
 Constructor. More...
 
 MessageImpl (byte type)
 Constructor for new messages. More...
 
 MessageImpl (byte type, ByteBuffer buffer, IMessageHeaderTransformer headerTransformer)
 Constructor for messages created from an incoming message buffer. For message types with headers this unpacks the header values and calls down to the ApplyHeaderValues method to capture and validate the headers. Any values required must be copied from the supplied buffer which should remain untouched. Also the message length must be determined from the length in the buffer rather than the buffer limit which could be longer. More...
 
void SetHeaderLength ()
 Sets the header length according to the sum of the current headers plus delimiters plus static header length. More...
 
List< string > GetAllHeaders ()
 Gets all headers (fixed and user). More...
 
virtual int GetNumberOfFixedHeaders ()
 Returns the number of fixed headers that the message has (must have). More...
 
virtual void ApplyFixedHeaders (List< string > headers, IMessageHeaderTransformer headerTransformer)
 This is used for messages that have headers when a message is created from an existing byte buffer. This is called during construction so that the subclasses can capture and validate the header field values. More...
 
virtual string GetAckId ()
 
virtual void SetFixedHeaders (params string[] headers)
 Sets fixed headers. This must be called during message construction. More...
 

Static Protected Member Functions

static void CheckHeaders (int length, params string[] headers)
 Utility method to check that the correct number of headers have been supplied. More...
 

Protected Attributes

List< string > theUserHeaders
 User headers. More...
 

Properties

int HeaderLength [get, set]
 Returns the length of the header. More...
 
bool SetMessageLengthOnWrite [get, set]
 Determines whether we set the message length explicitly prior to writing. More...
 
virtual byte MessageType [get, set]
 Get/set the type of this message. More...
 
bool HasHeaders [get]
 Does this message have headers? More...
 
byte Priority [get, set]
 Get/set the priority of this message. More...
 
bool IsExpedited [get, set]
 Get/set whether this message should be expedited. More...
 
List< string > FixedHeaders [get]
 Returns the collection of fixed headers. More...
 
string AckId [get, set]
 Get/set the acknowledgement id. More...
 
int DataPosition [get, set]
 Get/set the data position. Only useful when initialising from buffer. More...
 
override long Timestamp [get, set]
 Get/set the timestamp of this message. More...
 
override bool IsLocked [get, set]
 Get/set whether this message is locked. More...
 
bool HasUserHeaders [get]
 Returns whether this message has user headers. More...
 
- Properties inherited from PushTechnology.DiffusionCore.Messaging.MessageBase
abstract long Timestamp [get, set]
 
abstract bool IsLocked [get, set]
 

Additional Inherited Members

- Static Public Attributes inherited from PushTechnology.DiffusionCore.Messaging.MessageBase
static byte MESSAGE_DELIMITER
 Message delimiter. More...
 
static char MESSAGE_DELIMITER_CHAR = (char) 0x00
 Message delimiter character. More...
 
static byte RECORD_DELIMITER = 0x01
 Record delimiter. More...
 
static char RECORD_DELIMITER_CHAR = (char) 0x01
 Record delimiter character. More...
 
static byte FIELD_DELIMITER = 0x02
 Field delimiter. More...
 
static char FIELD_DELIMITER_CHAR = (char) 0x02
 Field delimiter character. More...
 
static byte MESSAGE_SEPARATOR = 0x08
 Message separator. More...
 
static char MESSAGE_SEPARATOR_CHAR = (char) 0x08
 Message separator character. More...
 
static char EMPTY_FIELD_CHAR = (char) 0x03
 Empty field character. More...
 
static string EMPTY_FIELD_STRING = EMPTY_FIELD_CHAR.ToString(CultureInfo.InvariantCulture)
 Empty field string. More...
 
static byte LIST_DELIMITER = 0x06
 Byte value reserved for use as a list delimiter used for separating the elements of a list in character-based messages. More...
 
static char LIST_DELIMITER_CHAR = (char) LIST_DELIMITER
 Character representation of LIST_DELIMITER. More...
 
static string LIST_DELIMITER_STRING = LIST_DELIMITER_CHAR.ToString(CultureInfo.InvariantCulture)
 String representation of LIST_DELIMITER. Useful for string.Join operations. More...
 

Detailed Description

This is the base class for all messages. All messages have the same basic format, that being:

LLLLTEheaderRbody

where:

LLLL is the total message length as a 32 bit signed twos complement integer giving a maximum message size of 2,147,483,647.

T is the message type (byte).

E is the message byte encoding indicating the byte encoding of the body of the message. This will be zero for message types that have no body.

headerR is the header which may be one or more field values separated by field delimiters and terminated by a record delimiter (R). Headers are optional so some message types may not have a header.

body is the message body. Some message types (control messages) have no body.

Some message types have neither a body or a header.

Constructor & Destructor Documentation

PushTechnology.DiffusionCore.Messaging.MessageImpl.MessageImpl ( IExternalMessage  message)
protected

Constructor.

Parameters
message
PushTechnology.DiffusionCore.Messaging.MessageImpl.MessageImpl ( byte  type)
protected

Constructor for new messages.

Parameters
type
PushTechnology.DiffusionCore.Messaging.MessageImpl.MessageImpl ( byte  type,
ByteBuffer  buffer,
IMessageHeaderTransformer  headerTransformer 
)
protected

Constructor for messages created from an incoming message buffer. For message types with headers this unpacks the header values and calls down to the ApplyHeaderValues method to capture and validate the headers. Any values required must be copied from the supplied buffer which should remain untouched. Also the message length must be determined from the length in the buffer rather than the buffer limit which could be longer.

Parameters
type
buffer
headerTransformer

Member Function Documentation

virtual void PushTechnology.DiffusionCore.Messaging.MessageImpl.AddFixedHeader ( string  header)
virtual

Can be used by subclasses to add an optional fixed header after creation.

Parameters
header

Reimplemented in PushTechnology.DiffusionCore.Messaging.DataMessageImpl.

virtual void PushTechnology.DiffusionCore.Messaging.MessageImpl.ApplyFixedHeaders ( List< string >  headers,
IMessageHeaderTransformer  headerTransformer 
)
protectedvirtual

This is used for messages that have headers when a message is created from an existing byte buffer. This is called during construction so that the subclasses can capture and validate the header field values.

Parameters
headersHeaders as read from input message.
headerTransformerAn optional header transformer object to be used as the subclass wishes.

Reimplemented in PushTechnology.DiffusionCore.Messaging.Topic.TopicMessageImpl, PushTechnology.DiffusionCore.Messaging.CommandLoadMessage, PushTechnology.DiffusionCore.Messaging.Topic.TopicLoadMessage, PushTechnology.DiffusionCore.Messaging.CommandNotificationMessage, PushTechnology.DiffusionCore.Messaging.TopicLoadMessageAck, PushTechnology.DiffusionCore.Messaging.DeltaMessageAck, and PushTechnology.DiffusionCore.Messaging.CommandMessage.

static void PushTechnology.DiffusionCore.Messaging.MessageImpl.CheckHeaders ( int  length,
params string[]  headers 
)
staticprotected

Utility method to check that the correct number of headers have been supplied.

Parameters
length
headers
override int PushTechnology.DiffusionCore.Messaging.MessageImpl.CompareTo ( IMessage  message)
virtual

Compares the current object with another object of the same type.

Returns
A 32-bit signed integer that indicates the relative order of the objects being compared. The return value has the following meanings: Value Meaning Less than zero This object is less than the message parameter. Zero This object is equal to message . Greater than zero This object is greater than message .
Parameters
messageAn object to compare with this object.

Implements PushTechnology.DiffusionCore.Messaging.MessageBase.

Reimplemented in PushTechnology.DiffusionCore.Messaging.Topic.TopicMessageImpl.

override int PushTechnology.DiffusionCore.Messaging.MessageImpl.CompareTo ( IMessage  message,
MessageComparator  comparator 
)
virtual

Compares this message to another message using a specified comparator.

Parameters
message
comparator
Returns

summary>

        Determines whether the specified <see cref="T:System.Object" /> is equal to the current <see cref="T:System.Object" />.

        /summary>

        returns>
            true if the specified <see cref="T:System.Object" /> is equal to the current <see cref="T:System.Object" />; otherwise, false.

        /returns>

            <param name="obj">
        The <see cref="T:System.Object" /> to compare with the current <see cref="T:System.Object" />. 
        </param>
            <exception cref="T:System.NullReferenceException">
        The <paramref name="obj" /> parameter is null.
        </exception><filterpriority>2</filterpriority>  

Implements PushTechnology.DiffusionCore.Messaging.MessageBase.

virtual string PushTechnology.DiffusionCore.Messaging.MessageImpl.GetAckId ( )
protectedvirtual
List<string> PushTechnology.DiffusionCore.Messaging.MessageImpl.GetAllHeaders ( )
protected

Gets all headers (fixed and user).

Returns
A list of all the headers - empty list when no headers.
abstract ByteBuffer PushTechnology.DiffusionCore.Messaging.MessageImpl.GetBufferForWriting ( ConnectionCapabilities  capabilities)
pure virtual

Returns the message in buffer format for writing. If the message is encoded or needs encoding then this will return the encoded version. However, if the supplied capabilities indicate that the caller can not handled the encoded version then the unencoded version would be returned.

Parameters
capabilitiescapabilities or null indicating ALL capabilities.
Returns

Implemented in PushTechnology.DiffusionCore.Messaging.DataMessageImpl.

override int PushTechnology.DiffusionCore.Messaging.MessageImpl.GetHashCode ( )

Returns
override string PushTechnology.DiffusionCore.Messaging.MessageImpl.GetHeader ( int  index)
virtual

Returns a header value.

Parameters
indexThe header index (first header has index 0)
Returns
The header value or null if there is no header with the given index.

Implements PushTechnology.DiffusionCore.Messaging.MessageBase.

override List<string> PushTechnology.DiffusionCore.Messaging.MessageImpl.GetHeaders ( )
virtual

Get the headers of this message.

Returns

Implements PushTechnology.DiffusionCore.Messaging.MessageBase.

abstract int PushTechnology.DiffusionCore.Messaging.MessageImpl.GetMessageLength ( )
pure virtual

Returns the total message length including header. Note that for an encoded data message this will return the encoded message length.

Returns

Implemented in PushTechnology.DiffusionCore.Messaging.DataMessageImpl.

virtual bool PushTechnology.DiffusionCore.Messaging.MessageImpl.IsControlMessage ( )
virtual
virtual bool PushTechnology.DiffusionCore.Messaging.MessageImpl.IsDataMessage ( )
virtual
override bool PushTechnology.DiffusionCore.Messaging.MessageImpl.IsTopicMessage ( )
virtual
virtual void PushTechnology.DiffusionCore.Messaging.MessageImpl.SetFixedHeaders ( params string[]  headers)
protectedvirtual

Sets fixed headers. This must be called during message construction.

Parameters
headers

Reimplemented in PushTechnology.DiffusionCore.Messaging.DataMessageImpl, and PushTechnology.DiffusionCore.Messaging.Topic.TopicLoadMessage.

void PushTechnology.DiffusionCore.Messaging.MessageImpl.SetHeaderLength ( )
protected

Sets the header length according to the sum of the current headers plus delimiters plus static header length.

override void PushTechnology.DiffusionCore.Messaging.MessageImpl.SetHeaders ( params string[]  headers)
virtual

Sets headers. One or more separate headers may be set as required. Headers may be set once and only once after constructing a message and before any data is added to the message.

Parameters
headers

Implements PushTechnology.DiffusionCore.Messaging.MessageBase.

override void PushTechnology.DiffusionCore.Messaging.MessageImpl.SetHeaders ( List< string >  headers)
virtual

Set the headers of this message.

Parameters
headers

Implements PushTechnology.DiffusionCore.Messaging.MessageBase.

void PushTechnology.DiffusionCore.Messaging.MessageImpl.Write ( ByteBuffer  buffer,
ConnectionCapabilities  capabilities 
)

Write the message to a byte buffer.

Parameters
buffer
capabilitiesThe connection capabilities which will determine whether the message written should be encoded or decoded. Null would indicates all possible capabilities.
void PushTechnology.DiffusionCore.Messaging.MessageImpl.Write ( SslStream  stream)

Writes the message to a secure stream.

Parameters
stream
void PushTechnology.DiffusionCore.Messaging.MessageImpl.Write ( ClientSocket  socket)

Write the message to a socket channel.

Parameters
socket
void PushTechnology.DiffusionCore.Messaging.MessageImpl.Write ( SslStream  stream,
ConnectionCapabilities  capabilities,
bool  async 
)

Write the message to a secure stream.

Parameters
stream
capabilities
async
void PushTechnology.DiffusionCore.Messaging.MessageImpl.Write ( ClientSocket  socket,
ConnectionCapabilities  capabilities 
)

Write the message to a socket channel.

Parameters
socket
capabilitiesThe connection capabilities which will determine whether the message written should be encoded or decoded.

Member Data Documentation

List<string> PushTechnology.DiffusionCore.Messaging.MessageImpl.theUserHeaders
protected

User headers.

Property Documentation

string PushTechnology.DiffusionCore.Messaging.MessageImpl.AckId
getset

Get/set the acknowledgement id.

int PushTechnology.DiffusionCore.Messaging.MessageImpl.DataPosition
getset

Get/set the data position. Only useful when initialising from buffer.

List<string> PushTechnology.DiffusionCore.Messaging.MessageImpl.FixedHeaders
get

Returns the collection of fixed headers.

bool PushTechnology.DiffusionCore.Messaging.MessageImpl.HasHeaders
get

Does this message have headers?

bool PushTechnology.DiffusionCore.Messaging.MessageImpl.HasUserHeaders
get

Returns whether this message has user headers.

int PushTechnology.DiffusionCore.Messaging.MessageImpl.HeaderLength
getset

Returns the length of the header.

bool PushTechnology.DiffusionCore.Messaging.MessageImpl.IsExpedited
getset

Get/set whether this message should be expedited.

override bool PushTechnology.DiffusionCore.Messaging.MessageImpl.IsLocked
getset

Get/set whether this message is locked.

virtual byte PushTechnology.DiffusionCore.Messaging.MessageImpl.MessageType
getset

Get/set the type of this message.

byte PushTechnology.DiffusionCore.Messaging.MessageImpl.Priority
getset

Get/set the priority of this message.

bool PushTechnology.DiffusionCore.Messaging.MessageImpl.SetMessageLengthOnWrite
getset

Determines whether we set the message length explicitly prior to writing.

override long PushTechnology.DiffusionCore.Messaging.MessageImpl.Timestamp
getset

Get/set the timestamp of this message.