cbitcoin
 All Data Structures Files Functions Variables Typedefs
src/structures/CBObject/CBMessage/CBMessage.h File Reference

Serialisable data structure. Provides the basic framework for serialising and deserialising bitcoin messages. Messages shouldn't be serialised including message headers. Message headers should be added before sending messages and removed when deserialising. Inherits CBObject. More...

#include <stdlib.h>
#include <stdbool.h>
#include "CBVarInt.h"

Go to the source code of this file.

Data Structures

struct  CBMessage
 Structure for CBMessage objects. More...

Typedefs

typedef struct CBMessage CBMessage
 Structure for CBMessage objects.

Functions

CBMessageCBNewMessageByObject (void(*onErrorReceived)(CBError error, char *,...))
 Creates a new CBMessage object. This message will be created with object data and not with byte data. The message can be serialised for the byte data used over the network.
CBMessageCBGetMessage (void *self)
 Gets a CBMessage from another object. Use this to avoid casts.
bool CBInitMessageByObject (CBMessage *self, void(*onErrorReceived)(CBError error, char *,...))
 Initialises a CBMessage object.
bool CBInitMessageByData (CBMessage *self, CBByteArray *data, void(*onErrorReceived)(CBError error, char *,...))
 Initialises a CBMessage object from byte data.
void CBFreeMessage (void *self)
 Frees a CBMessage object.

Detailed Description

Serialisable data structure. Provides the basic framework for serialising and deserialising bitcoin messages. Messages shouldn't be serialised including message headers. Message headers should be added before sending messages and removed when deserialising. Inherits CBObject.


Typedef Documentation

typedef struct CBMessage CBMessage

Structure for CBMessage objects.

See also:
CBMessage.h

Function Documentation

void CBFreeMessage ( void *  self)

Frees a CBMessage object.

Parameters:
selfThe CBMessage object to free.
CBMessage* CBGetMessage ( void *  self)

Gets a CBMessage from another object. Use this to avoid casts.

Parameters:
selfThe object to obtain the CBMessage from.
Returns:
The CBMessage object.
bool CBInitMessageByData ( CBMessage self,
CBByteArray data,
void(*)(CBError error, char *,...)  onErrorReceived 
)

Initialises a CBMessage object from byte data.

Parameters:
selfThe CBMessage object to initialise
dataThe byte data for the object. The data will not be copied but retained by this object.
Returns:
true on success, false on failure.
bool CBInitMessageByObject ( CBMessage self,
void(*)(CBError error, char *,...)  onErrorReceived 
)

Initialises a CBMessage object.

Parameters:
selfThe CBMessage object to initialise
Returns:
true on success, false on failure.
CBMessage* CBNewMessageByObject ( void(*)(CBError error, char *,...)  onErrorReceived)

Creates a new CBMessage object. This message will be created with object data and not with byte data. The message can be serialised for the byte data used over the network.

Parameters:
@returnsA new CBMessage object.