![]() |
Diffusion .NET Classic API - Core and Common
5.9.4
|
This is the implementation of the API DataMessage which is a message that has a data body. More...
Public Member Functions | |
DataMessageImpl (byte type, long initialSize) | |
Constructor. More... | |
DataMessageImpl (IExternalMessage message) | |
Constructor. More... | |
DataMessageImpl (byte type) | |
Constructor for new messages. Subclasses with headers must call SetFixedHeaders in their constructor. More... | |
DataMessageImpl (byte type, ByteBuffer buffer, IMessageHeaderTransformer headerTransformer) | |
Constructor for message created from inbound byte buffers. The supplied buffer will be copied and its position or limit will be unaffected. More... | |
override int | Size () |
Return the size of this message. More... | |
override int | Capacity () |
Return the capacity of this message. More... | |
override void | AddFixedHeader (string header) |
Adds a fixed header to this message. More... | |
override string | ToString () |
override int | GetMessageLength () |
Returns the total message length including headers. Note that for an encoded data message this will return the encoded message length. More... | |
override 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... | |
ByteBuffer | GetBufferForReading () |
Get a buffer for reading. More... | |
override bool | IsDataMessage () |
override void | SetHeaders (List< string > headers) |
Sets the headers. More... | |
override void | SetHeaders (params string[] headers) |
Sets the headers. More... | |
void | SetEncoding (byte encoding) |
Sets the byte encoding for the message and encodes it. More... | |
void | Rewind () |
Rewinds the message pointer to the start of the data portion, leaving the message limit as before. This prepares the buffer for reading after being written. More... | |
void | Put (ByteBuffer buffer) |
Relative put of data from a ByteBuffer. More... | |
int | BufferPosition () |
Used for getting the current position of the readable buffer. More... | |
void | BufferPosition (int position) |
Used for setting the position of the readable buffer. More... | |
void | Put (byte data) |
Relative put of a single byte of data. More... | |
void | Put (byte[] data) |
Relative put of a byte array of data. More... | |
void | Put (params string[] data) |
Relative put of string data. Converts supplied string(s) to bytes using the messages character set encoding and puts the bytes into the message starting from the current position. Multiple strings are concatenated. More... | |
void | Put (IDataMessage message) |
Puts the entire contents of another message into this message. More... | |
void | PutRecord (params string[] fields) |
Relative put of a set of string fields as a record. The specified fields are written to the message delimited by field delimiters. If there is already data in the buffer that is not terminated by a record delimiter, then a record delimiter will first be written to the message. More... | |
void | PutRecord (params byte[] fields) |
Relative put of a set of byte array fields as a record. The specified fields are written to the message delimited by field delimiters. If there is already data in the buffer that is not terminated by a record delimiter, then a record delimiter will first be written to the message. More... | |
void | PutRecords (params Record[] records) |
Relative put of one or more records. The fields of each record are written to the message delimited by field delimiters and the records themselves are delimited by record delimiters, strings are converted to bytes using the character set of the message. The message pointer is then updated. If there is already data in the buffer that is not terminated by a record delimiter, then a record delimiter will first be written to the message. Record delimiters will then be written at the start of each subsequent record. Null entries are interpreted as empty records. More... | |
void | PutRecords (List< Record > records) |
Relative put of one or more records from a collection. More... | |
void | PutFields (string[] fields) |
Relative put of one or more string fields. If there is already data in the buffer which is not terminated by a record or field delimiter, then a field delimiter will be written followed by the specified fields separated by field delimiters. More... | |
void | PutFields (params byte[] fields) |
Relative put of one or more byte array fields. Puts the bytes into the message starting from the current position. Multiple fields are separated by field delimiters. The message position is then updated. If there is already data in the buffer which is not terminated by a record or field delimiter, then a field delimiter will be written followed by the specified fields separated by field delimiters. If any field value is null it will be written as an empty field. More... | |
string | AsString () |
Returns the whole message body as a string. The message's character set will be used to convert the message bytes to a string. More... | |
byte[] | AsBytes () |
Returns the whole message as a byte array. More... | |
ByteBuffer | AsByteBuffer () |
Returns the whole message data content as a newly allocated ByteBuffer. This operation does not affect the message pointer. More... | |
List< string > | AsFields () |
Returns the whole message body as fields. Fields are delimited by field delimiters. If there are no such delimiters then a single field would be returned. The message's character set will be used to convert the message bytes to a string. This operation does not affect the message pointer. More... | |
List< Record > | AsRecords () |
Returns the whole message body as records. Records are delimited by record delimiters. If there are no such delimiters then a single record would be returned. This operation does not affect the message pointer. More... | |
List< Record > | AsRecords (IMRecord metadata) |
Returns the whole message body as records. This is similar to AsRecords() except that the structure of the supplied metadata is assumed for each record and the records returned can be accessed using metadata specific methods. More... | |
string | MessageDetails () |
Returns the details of the message in 'L=...,T=...,E=...' format. More... | |
int | Available () |
Indicates the free space available for writing to in bytes. If the message is in a read only state then this will return 0. If the message is writable then this will return the number of bytes of bytes of data that may be written before the message becomes full. It is important to note that this returns the number of free bytes and not necessarily the number of characters that may be written as depending upon the character set in use the number of bytes required to write a character may vary. More... | |
byte | NextByte () |
Returns the next byte of data from the message. More... | |
byte | NextByte (ByteBuffer buffer) |
Next byte in buffer. More... | |
void | NextBytes (byte[] destination) |
Returns data from the message as bytes from the current position. More... | |
void | NextBytes (ByteBuffer buffer, byte[] destination) |
Next bytes in buffer. More... | |
Record | NextRecord () |
Relative get of a record of string data. More... | |
Record | NextRecord (IMRecord metadata) |
Returns a record of string data from the current message position using a metadata definition. This is similar to NextRecord() except the the structure of the supplied metadata is assumed for the record and the record returned can be accessed using metadata-specific methods. More... | |
Record | NextRecord (ByteBuffer buffer, IMRecord metadata) |
Returns the next record in the buffer. More... | |
string | NextField (ByteBuffer buffer) |
Return the next field from a byte buffer. More... | |
string | NextField () |
Relative get of a field of string data. More... | |
void | PutObject (object obj) |
Writes an object to the message using object serialization. More... | |
void | WriteToHttpBuffer (ByteBuffer buffer) |
Writes the message to an HTTP output buffer in the correct format. The buffer must be correctly positioned with sufficient limit. More... | |
void | SetBodyFromMessage (DataMessageImpl message) |
Sets the body of this message from another message. This is only to be used during construction. The encoded state is also copied so the buffer state of the input message is copied to this message leaving this message in the same encoding state as the source message. More... | |
bool | Encode () |
Encodes the message (if it needs it). returns true if encoded (or already encoded) or false if encoding was not necessary. More... | |
void | Decode (bool keepEncoded) |
Decodes the message. More... | |
void | Dispose () |
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. More... | |
Protected Member Functions | |
DataMessageImpl (byte type, int capacity) | |
Constructor. More... | |
DataMessageImpl (byte type, int capacity, MessageEncodingType?encoding) | |
Constructor for new messages. Subclasses with headers must call SetHeaders in their constructor. More... | |
void | SetFixedHeaders (TopicAliasMap topicAliasMap, params string[] headers) |
Sets headers allowing for transformation of the topic name. More... | |
override void | SetFixedHeaders (params string[] headers) |
Sets the fixed header fields. This is only called during the construction of a new message. More... | |
Properties | |
override byte | MessageType [get, set] |
Get/set the type of this message. More... | |
ByteBuffer | InternalBuffer [get] |
Provides public access to the underlying byte buffer. Primarily for debugging purposes. More... | |
string | Charset [get, set] |
Returns the character set to be used by the message for byte/character conversions. More... | |
bool | HasRemaining [get] |
Indicates whether the message has any remaining data to read. More... | |
int | Remaining [get] |
Indicates the number of unread data bytes remaining within the message. More... | |
int | Length [get] |
Returns the length of the data within the message. More... | |
byte | TheEncoding [get] |
Returns the message encoding. More... | |
IMessageReader | Reader [get] |
This returns a reader which may be used to perform relative read operations on a message without affecting the pointers of the original message. More... | |
DataMessageInputStream | InputStream [get] |
Returns a binary reader which may be used for reading bytes from the message. More... | |
DataMessageOutputStream | OutputStream [get] |
Returns a binary writer which may be used for writing bytes to the message. More... | |
Additional Inherited Members |
This is the implementation of the API DataMessage which is a message that has a data body.
PushTechnology.DiffusionCore.Messaging.DataMessageImpl.DataMessageImpl | ( | byte | type, |
long | initialSize | ||
) |
Constructor.
type | |
initialSize |
PushTechnology.DiffusionCore.Messaging.DataMessageImpl.DataMessageImpl | ( | IExternalMessage | message | ) |
Constructor.
message |
|
protected |
Constructor.
type | |
capacity |
|
protected |
Constructor for new messages. Subclasses with headers must call SetHeaders in their constructor.
type | |
capacity | |
encoding |
PushTechnology.DiffusionCore.Messaging.DataMessageImpl.DataMessageImpl | ( | byte | type | ) |
Constructor for new messages. Subclasses with headers must call SetFixedHeaders in their constructor.
type |
PushTechnology.DiffusionCore.Messaging.DataMessageImpl.DataMessageImpl | ( | byte | type, |
ByteBuffer | buffer, | ||
IMessageHeaderTransformer | headerTransformer | ||
) |
Constructor for message created from inbound byte buffers. The supplied buffer will be copied and its position or limit will be unaffected.
type | |
buffer | |
headerTransformer |
|
virtual |
Adds a fixed header to this message.
header |
summary>
Returns a <see cref="T:System.String" /> that represents the current <see cref="T:System.Object" />. /summary> returns> A <see cref="T:System.String" /> that represents the current <see cref="T:System.Object" />. /returns> filterpriority>2</filterpriority>
Reimplemented from PushTechnology.DiffusionCore.Messaging.MessageImpl.
ByteBuffer PushTechnology.DiffusionCore.Messaging.DataMessageImpl.AsByteBuffer | ( | ) |
Returns the whole message data content as a newly allocated ByteBuffer. This operation does not affect the message pointer.
byte [] PushTechnology.DiffusionCore.Messaging.DataMessageImpl.AsBytes | ( | ) |
Returns the whole message as a byte array.
List<string> PushTechnology.DiffusionCore.Messaging.DataMessageImpl.AsFields | ( | ) |
Returns the whole message body as fields. Fields are delimited by field delimiters. If there are no such delimiters then a single field would be returned. The message's character set will be used to convert the message bytes to a string. This operation does not affect the message pointer.
List<Record> PushTechnology.DiffusionCore.Messaging.DataMessageImpl.AsRecords | ( | ) |
Returns the whole message body as records. Records are delimited by record delimiters. If there are no such delimiters then a single record would be returned. This operation does not affect the message pointer.
Returns the whole message body as records. This is similar to AsRecords() except that the structure of the supplied metadata is assumed for each record and the records returned can be accessed using metadata specific methods.
metadata | The metadata that defines each record. This must either be a simple IMRecord definition or an IMMessage which defines a single record. The data type of the metadata must be RECORD. |
string PushTechnology.DiffusionCore.Messaging.DataMessageImpl.AsString | ( | ) |
Returns the whole message body as a string. The message's character set will be used to convert the message bytes to a string.
int PushTechnology.DiffusionCore.Messaging.DataMessageImpl.Available | ( | ) |
Indicates the free space available for writing to in bytes. If the message is in a read only state then this will return 0. If the message is writable then this will return the number of bytes of bytes of data that may be written before the message becomes full. It is important to note that this returns the number of free bytes and not necessarily the number of characters that may be written as depending upon the character set in use the number of bytes required to write a character may vary.
int PushTechnology.DiffusionCore.Messaging.DataMessageImpl.BufferPosition | ( | ) |
Used for getting the current position of the readable buffer.
void PushTechnology.DiffusionCore.Messaging.DataMessageImpl.BufferPosition | ( | int | position | ) |
Used for setting the position of the readable buffer.
position |
|
virtual |
Return the capacity of this message.
Implements PushTechnology.DiffusionCore.Messaging.MessageBase.
void PushTechnology.DiffusionCore.Messaging.DataMessageImpl.Decode | ( | bool | keepEncoded | ) |
Decodes the message.
keepEncoded | indicates whether we should keep the encoded version (which you might do if you just wanted to read the message but then send it out again, thus avoiding re-encoding) or discard the encoded version (which would be best if do not plan to send the message out again as it will save space). |
void PushTechnology.DiffusionCore.Messaging.DataMessageImpl.Dispose | ( | ) |
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
<filterpriority>2</filterpriority>
bool PushTechnology.DiffusionCore.Messaging.DataMessageImpl.Encode | ( | ) |
Encodes the message (if it needs it). returns true if encoded (or already encoded) or false if encoding was not necessary.
ByteBuffer PushTechnology.DiffusionCore.Messaging.DataMessageImpl.GetBufferForReading | ( | ) |
Get a buffer for reading.
|
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.
capabilities | capabilities or null indicating ALL capabilities. |
Implements PushTechnology.DiffusionCore.Messaging.MessageImpl.
|
virtual |
Returns the total message length including headers. Note that for an encoded data message this will return the encoded message length.
Implements PushTechnology.DiffusionCore.Messaging.MessageImpl.
|
virtual |
Reimplemented from PushTechnology.DiffusionCore.Messaging.MessageImpl.
string PushTechnology.DiffusionCore.Messaging.DataMessageImpl.MessageDetails | ( | ) |
Returns the details of the message in 'L=...,T=...,E=...' format.
byte PushTechnology.DiffusionCore.Messaging.DataMessageImpl.NextByte | ( | ) |
Returns the next byte of data from the message.
The byte of data at the current position is returned and the position updated.
byte PushTechnology.DiffusionCore.Messaging.DataMessageImpl.NextByte | ( | ByteBuffer | buffer | ) |
Next byte in buffer.
buffer |
void PushTechnology.DiffusionCore.Messaging.DataMessageImpl.NextBytes | ( | byte[] | destination | ) |
Returns data from the message as bytes from the current position.
Bytes from current message position are transferred into the specified
destination array until the destination array is filled. The message position is then updated.
destination |
void PushTechnology.DiffusionCore.Messaging.DataMessageImpl.NextBytes | ( | ByteBuffer | buffer, |
byte[] | destination | ||
) |
Next bytes in buffer.
buffer | |
destination |
string PushTechnology.DiffusionCore.Messaging.DataMessageImpl.NextField | ( | ByteBuffer | buffer | ) |
Return the next field from a byte buffer.
buffer |
string PushTechnology.DiffusionCore.Messaging.DataMessageImpl.NextField | ( | ) |
Relative get of a field of string data.
This returns a field of string data constructed from bytes read from the current data buffer position to the next field delimiter (or record delimiter) within the buffer, or the end of the message.
The 'HasRemaining' property should be called before calling this method.
After calling this method, the data buffer pointer will be moved beyond the delimiter found.
Record PushTechnology.DiffusionCore.Messaging.DataMessageImpl.NextRecord | ( | ) |
Relative get of a record of string data.
This returns a record of string data read from the current data buffer position to the next record delimiter within the buffer, or the end of the message. Fields (areas delimited by field delimiters) are unpacked from within the record area. If there are no field delimiters, then the returned record will contain only one field.
The 'HasRemaining' property should be called before calling this method.
After calling this method, the data buffer pointer will be moved beyond the record read.
Returns a record of string data from the current message position using a metadata definition. This is similar to NextRecord() except the the structure of the supplied metadata is assumed for the record and the record returned can be accessed using metadata-specific methods.
metadata | The metadata that defines the record. This must either be a simple IMRecord definition or an IMMessage which defines a single record. The data type of the metadata must be RECORD. |
Record PushTechnology.DiffusionCore.Messaging.DataMessageImpl.NextRecord | ( | ByteBuffer | buffer, |
IMRecord | metadata | ||
) |
Returns the next record in the buffer.
buffer | |
metadata |
void PushTechnology.DiffusionCore.Messaging.DataMessageImpl.Put | ( | ByteBuffer | buffer | ) |
Relative put of data from a ByteBuffer.
This method transfers the bytes remaining in the given source buffer into this message.
buffer |
void PushTechnology.DiffusionCore.Messaging.DataMessageImpl.Put | ( | byte | data | ) |
Relative put of a single byte of data.
data |
void PushTechnology.DiffusionCore.Messaging.DataMessageImpl.Put | ( | byte[] | data | ) |
Relative put of a byte array of data.
data |
void PushTechnology.DiffusionCore.Messaging.DataMessageImpl.Put | ( | params string[] | data | ) |
Relative put of string data. Converts supplied string(s) to bytes using the messages character set encoding and puts the bytes into the message starting from the current position. Multiple strings are concatenated.
data |
void PushTechnology.DiffusionCore.Messaging.DataMessageImpl.Put | ( | IDataMessage | message | ) |
Puts the entire contents of another message into this message.
All data bytes are copied from the source message into this message starting from the current position. The message position is then updated.
message | The message to copy data from. |
void PushTechnology.DiffusionCore.Messaging.DataMessageImpl.PutFields | ( | string[] | fields | ) |
Relative put of one or more string fields. If there is already data in the buffer which is not terminated by a record or field delimiter, then a field delimiter will be written followed by the specified fields separated by field delimiters.
fields |
void PushTechnology.DiffusionCore.Messaging.DataMessageImpl.PutFields | ( | params byte[] | fields | ) |
Relative put of one or more byte array fields. Puts the bytes into the message starting from the current position. Multiple fields are separated by field delimiters. The message position is then updated. If there is already data in the buffer which is not terminated by a record or field delimiter, then a field delimiter will be written followed by the specified fields separated by field delimiters. If any field value is null it will be written as an empty field.
fields | The list of fields. |
void PushTechnology.DiffusionCore.Messaging.DataMessageImpl.PutObject | ( | object | obj | ) |
Writes an object to the message using object serialization.
The object to be written must be serializable.
The object is written to the message from the current position using
obj | The object to write to the message |
void PushTechnology.DiffusionCore.Messaging.DataMessageImpl.PutRecord | ( | params string[] | fields | ) |
Relative put of a set of string fields as a record. The specified fields are written to the message delimited by field delimiters. If there is already data in the buffer that is not terminated by a record delimiter, then a record delimiter will first be written to the message.
fields |
void PushTechnology.DiffusionCore.Messaging.DataMessageImpl.PutRecord | ( | params byte[] | fields | ) |
Relative put of a set of byte array fields as a record. The specified fields are written to the message delimited by field delimiters. If there is already data in the buffer that is not terminated by a record delimiter, then a record delimiter will first be written to the message.
fields | One or more byte array fields. |
void PushTechnology.DiffusionCore.Messaging.DataMessageImpl.PutRecords | ( | params Record[] | records | ) |
Relative put of one or more records. The fields of each record are written to the message delimited by field delimiters and the records themselves are delimited by record delimiters, strings are converted to bytes using the character set of the message. The message pointer is then updated. If there is already data in the buffer that is not terminated by a record delimiter, then a record delimiter will first be written to the message. Record delimiters will then be written at the start of each subsequent record. Null entries are interpreted as empty records.
records | The records - zero or more can be specified. |
void PushTechnology.DiffusionCore.Messaging.DataMessageImpl.PutRecords | ( | List< Record > | records | ) |
Relative put of one or more records from a collection.
records | The collection of records. |
void PushTechnology.DiffusionCore.Messaging.DataMessageImpl.Rewind | ( | ) |
Rewinds the message pointer to the start of the data portion, leaving the message limit as before. This prepares the buffer for reading after being written.
void PushTechnology.DiffusionCore.Messaging.DataMessageImpl.SetBodyFromMessage | ( | DataMessageImpl | message | ) |
Sets the body of this message from another message. This is only to be used during construction. The encoded state is also copied so the buffer state of the input message is copied to this message leaving this message in the same encoding state as the source message.
message |
void PushTechnology.DiffusionCore.Messaging.DataMessageImpl.SetEncoding | ( | byte | encoding | ) |
Sets the byte encoding for the message and encodes it.
encoding |
|
protected |
Sets headers allowing for transformation of the topic name.
topicAliasMap | |
headers |
|
protectedvirtual |
Sets the fixed header fields. This is only called during the construction of a new message.
headers |
Reimplemented from PushTechnology.DiffusionCore.Messaging.MessageImpl.
Reimplemented in PushTechnology.DiffusionCore.Messaging.Topic.TopicLoadMessage.
|
virtual |
|
virtual |
|
virtual |
Return the size of this message.
Reimplemented from PushTechnology.DiffusionCore.Messaging.MessageBase.
void PushTechnology.DiffusionCore.Messaging.DataMessageImpl.WriteToHttpBuffer | ( | ByteBuffer | buffer | ) |
Writes the message to an HTTP output buffer in the correct format. The buffer must be correctly positioned with sufficient limit.
buffer |
|
getset |
Returns the character set to be used by the message for byte/character conversions.
|
get |
Indicates whether the message has any remaining data to read.
|
get |
Returns a binary reader which may be used for reading bytes from the message.
Reading will take place from the current message position.
|
get |
Provides public access to the underlying byte buffer. Primarily for debugging purposes.
|
get |
Returns the length of the data within the message.
|
getset |
Get/set the type of this message.
|
get |
Returns a binary writer which may be used for writing bytes to the message.
Writing will take place from the current message position.
|
get |
This returns a reader which may be used to perform relative read operations on a message without affecting the pointers of the original message.
This may be used where there is a need for more than one thread to be able to read the same message as the standard relative read and put operations on a message are not threadsafe.
Note that any such reader maintains a reference to the message and thus would prevent it from being garbage collected.
|
get |
Indicates the number of unread data bytes remaining within the message.
|
get |
Returns the message encoding.
The encoding value represents the byte encoding that will be applied to the message when it is sent.