Ixian SDK
IXICore.CoreProtocolMessage Class Reference

Common functions for manipulating Ixian protocol message. More...

Static Public Member Functions

static byte getHeaderChecksum (byte[] header)
 Calculates a single-byte checksum from the given header. More...
 
static byte [] prepareProtocolMessage (ProtocolMessageCode code, byte[] data, byte[] checksum=null)
 Prepares (serializes) a protocol message from the given Ixian message code and appropriate data. Checksum can be supplied, but if it isn't, this function will calculate it using the default method. More...
 
static void sendBye (RemoteEndpoint endpoint, ProtocolByeCode code, string message, string data, bool removeAddressEntry=true)
 Prepares and sends the disconnect message to the specified remote endpoint. More...
 
static void readProtocolMessage (byte[] recv_buffer, RemoteEndpoint endpoint)
 Reads a protocol message from the specified byte-field and calls appropriate methods to process this message. More...
 
static bool processHelloMessage (RemoteEndpoint endpoint, BinaryReader reader)
 Processes a Hello Ixian protocol message and updates the PresenceList as appropriate. More...
 
static void sendHelloMessage (RemoteEndpoint endpoint, bool sendHelloData, byte[] challenge_response)
 Prepares and sends an Ixian protocol 'Hello' message to the specified remote endpoint. More...
 
static bool broadcastProtocolMessage (char[] types, ProtocolMessageCode code, byte[] data, byte[] helper_data, RemoteEndpoint skipEndpoint=null)
 Prepares and broadcasts an Ixian protocol message to all connected nodes, filtered by types. More...
 
static bool broadcastEventDataMessage (NetworkEvents.Type type, byte[] address, ProtocolMessageCode code, byte[] data, byte[] helper_data, RemoteEndpoint skipEndpoint=null)
 Broadcasts an event message to all clients who are subscribed to receive the specific event type and wallet address. More...
 
static bool broadcastProtocolMessageToSingleRandomNode (char[] types, ProtocolMessageCode code, byte[] data, ulong block_num, RemoteEndpoint skipEndpoint=null)
 Sends the specified protocol message to one of the connected remote endpoints, chosen randomly. More...
 
static bool checkNodeConnectivity (RemoteEndpoint endpoint)
 Verifies that the given remote endpoint is reachable by connecting to it and sending a short message. More...
 

Detailed Description

Common functions for manipulating Ixian protocol message.

Definition at line 14 of file CoreNetworkProtocol.cs.

Member Function Documentation

◆ broadcastEventDataMessage()

static bool IXICore.CoreProtocolMessage.broadcastEventDataMessage ( NetworkEvents.Type  type,
byte []  address,
ProtocolMessageCode  code,
byte []  data,
byte []  helper_data,
RemoteEndpoint  skipEndpoint = null 
)
static

Broadcasts an event message to all clients who are subscribed to receive the specific event type and wallet address.

Events are filtered by type and address. A client must subscribe to the specifif type for specific addresses in order to receive this data. The payload data should be properly formatted for the given code - this function will not ensure that this is so and the caller must provide a valid message to this function. The skipEndpoint parameter is useful when re-broadcasting a message received from a specific endpoint and do not wish to echo the same data back to the sender.

Parameters
typeType of the event message - used to filter subscribers
addressAddress, which triggered the event.
codeIxian protocol code.
dataPayload data.
helper_dataOptional additional data, as required by code.
skipEndpointEndpoint to skip when broadcasting.
Returns
True, if at least one message was sent to at least one remote endpoint. False if no messages were sent.

Definition at line 571 of file CoreNetworkProtocol.cs.

◆ broadcastProtocolMessage()

static bool IXICore.CoreProtocolMessage.broadcastProtocolMessage ( char []  types,
ProtocolMessageCode  code,
byte []  data,
byte []  helper_data,
RemoteEndpoint  skipEndpoint = null 
)
static

Prepares and broadcasts an Ixian protocol message to all connected nodes, filtered by types.

The payload data should be properly formatted for the given code - this function will not ensure that this is so and the caller must provide a valid message to this function. The skipEndpoint parameter is useful when re-broadcasting a message received from a specific endpoint and do not wish to echo the same data back to the sender.

Parameters
typesTypes of nodes to send this message to.
codeProtocol code.
dataMessage payload
helper_dataAdditional information, as required by the protocol message
skipEndpointRemote endpoint which should be skipped (data should not be sent to it).
Returns
True, if at least one message was sent to at least one other node. False if no messages were sent.

Definition at line 535 of file CoreNetworkProtocol.cs.

◆ broadcastProtocolMessageToSingleRandomNode()

static bool IXICore.CoreProtocolMessage.broadcastProtocolMessageToSingleRandomNode ( char []  types,
ProtocolMessageCode  code,
byte []  data,
ulong  block_num,
RemoteEndpoint  skipEndpoint = null 
)
static

Sends the specified protocol message to one of the connected remote endpoints, chosen randomly.

The payload data should be properly formatted for the given code - this function will not ensure that this is so and the caller must provide a valid message to this function. The skipEndpoint parameter is useful when re-broadcasting a message received from a specific endpoint and do not wish to echo the same data back to the sender. The block_num parameter is used to filter the remote endpoints based on their latest known block height.

Parameters
typesTypes of the nodes where the message should be sent.
codeIxian protocol code.
dataPayload data.
block_numBlock which should be searched for the endpoint addresses.
skipEndpointMinimum block height for endpoints which should receive this message.
Returns
True, if at least one message was sent to at least one remote endpoint. False if no messages were sent.

Definition at line 596 of file CoreNetworkProtocol.cs.

◆ checkNodeConnectivity()

static bool IXICore.CoreProtocolMessage.checkNodeConnectivity ( RemoteEndpoint  endpoint)
static

Verifies that the given remote endpoint is reachable by connecting to it and sending a short message.

This function is used to ensure that the remote endpoing has listed the correct IP and port information for their PresenceList entry.

Parameters
endpointTarget endpoint to verify for connectivity.
Returns
True, if the endpoing is connectable.

Definition at line 702 of file CoreNetworkProtocol.cs.

◆ getHeaderChecksum()

static byte IXICore.CoreProtocolMessage.getHeaderChecksum ( byte []  header)
static

Calculates a single-byte checksum from the given header.

A single byte of checksum is not extremely robust, but it is simple and fast.

Parameters
headerMessage header.
Returns
Checksum byte.

Definition at line 24 of file CoreNetworkProtocol.cs.

◆ prepareProtocolMessage()

static byte [] IXICore.CoreProtocolMessage.prepareProtocolMessage ( ProtocolMessageCode  code,
byte []  data,
byte []  checksum = null 
)
static

Prepares (serializes) a protocol message from the given Ixian message code and appropriate data. Checksum can be supplied, but if it isn't, this function will calculate it using the default method.

This function can be used from the server and client side. Please note: This function does not validate that the payload data conforms to the expected message for code. It is the caller's job to ensure that.

Parameters
codeMessage code.
dataPayload for the message.
checksumOptional checksum. If not supplied, or if null, this function will calculate it with the default method.
Returns
Serialized message as a byte-field

Definition at line 47 of file CoreNetworkProtocol.cs.

◆ processHelloMessage()

static bool IXICore.CoreProtocolMessage.processHelloMessage ( RemoteEndpoint  endpoint,
BinaryReader  reader 
)
static

Processes a Hello Ixian protocol message and updates the PresenceList as appropriate.

This function should normally be called from NetworkProtocol.parseProtocolMessage()

Parameters
endpointRemote endpoint from which the message was received.
readerReader object placed at the beginning of the hello message data.
Returns
True if the message was formatted properly and accepted.

Definition at line 228 of file CoreNetworkProtocol.cs.

◆ readProtocolMessage()

static void IXICore.CoreProtocolMessage.readProtocolMessage ( byte []  recv_buffer,
RemoteEndpoint  endpoint 
)
static

Reads a protocol message from the specified byte-field and calls appropriate methods to process this message.

This function checks all applicable checksums and validates that the message is complete before calling one of the specialized methods to handle actual decoding and processing.

Parameters
recv_bufferByte-field with an Ixian protocol message.
endpointRemote endpoint from where the message was received.

Definition at line 141 of file CoreNetworkProtocol.cs.

◆ sendBye()

static void IXICore.CoreProtocolMessage.sendBye ( RemoteEndpoint  endpoint,
ProtocolByeCode  code,
string  message,
string  data,
bool  removeAddressEntry = true 
)
static

Prepares and sends the disconnect message to the specified remote endpoint.

Parameters
endpointRemote client.
codeDisconnection reason.
messageOptional text message for the user of the remote client.
dataOptional payload to further explain the disconnection reason.
removeAddressEntryIf true, the remote address will be removed from the PresenceList.

Definition at line 104 of file CoreNetworkProtocol.cs.

◆ sendHelloMessage()

static void IXICore.CoreProtocolMessage.sendHelloMessage ( RemoteEndpoint  endpoint,
bool  sendHelloData,
byte []  challenge_response 
)
static

Prepares and sends an Ixian protocol 'Hello' message to the specified remote endpoint.

A valid Ixian 'Hello' message includes certain Node data, verified by a public-key signature, which this function prepares using the primary wallet's keypair. If this message is a reply to the other endpoint's hello message, then

Parameters
endpointRemote endpoint to send the message to.
sendHelloDataTrue if the message is the first hello sent to the remote node, false if it is a reply to the challenge.
challenge_responseResponse byte-field to the other node's hello challenge

Definition at line 415 of file CoreNetworkProtocol.cs.


The documentation for this class was generated from the following file: