C# Class Brod.Messages.Message

ファイルを表示 Open project: paralect/brod Class Usage Examples

Public Methods

Method Description
CalculateMessageLength ( Int32 payloadLength ) : Int32

Calculate message length based on payload length

CalculateOnDiskMessageLength ( Int32 payloadLength ) : Int32

Calculate "on-disk" message length based on payload length. It differ from CalculateMessageLengh by additional 4 bytes that occupied by message lengh Int32 value

CalculatePayloadLength ( Int32 messageLength ) : Int32

Calculate payload length based on message length

CreateMessage ( byte payload ) : Message

Factory method for creating message with payload

Validate ( ) : void

Validate message by computing CRC32 hash for payload and comparing with Crc property. Throws exception if validation fails.

Private Methods

Method Description
ByteArraysEqual ( byte b1, byte b2 ) : bool

Trivial, yet efficient, byte array comparison

Method Details

CalculateMessageLength() public static method

Calculate message length based on payload length
public static CalculateMessageLength ( Int32 payloadLength ) : Int32
payloadLength System.Int32
return System.Int32

CalculateOnDiskMessageLength() public static method

Calculate "on-disk" message length based on payload length. It differ from CalculateMessageLengh by additional 4 bytes that occupied by message lengh Int32 value
public static CalculateOnDiskMessageLength ( Int32 payloadLength ) : Int32
payloadLength System.Int32
return System.Int32

CalculatePayloadLength() public static method

Calculate payload length based on message length
public static CalculatePayloadLength ( Int32 messageLength ) : Int32
messageLength System.Int32
return System.Int32

CreateMessage() public static method

Factory method for creating message with payload
public static CreateMessage ( byte payload ) : Message
payload byte
return Message

Validate() public method

Validate message by computing CRC32 hash for payload and comparing with Crc property. Throws exception if validation fails.
public Validate ( ) : void
return void