In file /home/eternity/Source/Common/Sender/H/sender.h:

class Sender : public Runable, public Shutdownable

Sender class

Inheritance:

Sender < Runable < Debugable

Sender < Shutdownable


Public Methods

unsigned long Sender::ConvertToNumericIP (char *addr)
Converts string address into the unsigned long
Err Sender::DispatchMsg (GMessage *msg)
Send a message over the network
void Sender::DispatcherThread (GMessage *msg)
Connect to one of the recipients and send him the message
GMessage* Sender::MakeMessageForSendingToMix (GMessage *chunk)
Add recipient to message
void* Sender::Run (void *)
Generic Sender Run() method
Sender::Sender (LogFile * senderLogFile, Killer * killer, MessageQueue * toSenderQueue, string origin, string IP = "", unsigned short port = 0)
Generic sender constructor
void Sender::Shutdown ()
Prepare for clean shutdown
Err Sender::WriteMsgToSocket (int sock, GMessage *msg)
Write message to connected socket
Sender::~Sender ()
Generic Sender destructor

Public

methods
Sender (LogFile * senderLogFile, Killer * killer, MessageQueue * toSenderQueue, string origin, string IP = "", unsigned short port = 0)
Constructor
virtual ~Sender ()
Destructor
void* Run (void *)
Main thread function
Err DispatchMsg (GMessage *msg)
Take care of this one message
void DispatcherThread (GMessage *msg)
method that runs in a separate thread and sends the message
virtual void Shutdown ()
Prepare for clean shutdown
GMessage* MakeMessageForSendingToMix (GMessage *chunk)
Insert default address and port to recipient

Protected

attributes
MessageQueue* toSenderQueue
Incoming queue
string origin
What set as GM_ORIGIN
string IP
IP address to send by default
unsigned short port
Port to send by default
methods
unsigned long ConvertToNumericIP (char *addr)
string -> long representation
Err WriteMsgToSocket (int sock, GMessage *msg)
Feed the raw data to socket

Inherited from Runable:

Public Methods

void Runable::MaskAllSignals()
Runable::Runable(LogFile * logFile)

Inherited from Debugable:

Public Methods

string* Debugable::CreateString(char *firstStr, int firstInt, int secondInt)
Debugable::Debugable(LogFile * debugLogFile)
int Debugable::SetDebugOptions(int newLogOptions)
void Debugable::SetLogFile(LogFile *aLogFile)
void Debugable::WriteString(LogLevel debugLevel, char * format, ...)
Debugable::~Debugable()

Inherited from Shutdownable:

Public Methods

Shutdownable::Shutdownable(Killer * killer)

Documentation

Sender class. Sends messages across network to other Mix or Six Expects a GMessage containing:
GM_RECIPIENT_1
GM_RECIPIENT_2
GM_CHUNK
GM_DEBUG
GM_PROTOCOL_VERSION
GM_REST_OF_PATH
GM_DATA
Makes a message like this and transmits it over network to IP from field Recipient.
GM_CHUNK
GM_RECIPIENT
GM_DEBUG
PROTOCOL_VERSION
GM_REST_OF_PATH
GM_DATA
The GM_RECIPIENT is set to GM_RECIPIENT_1 or GM_RECIPIENT_2 depending on which was used as destination address.
attributes

MessageQueue* toSenderQueue
Incoming queue

string origin
What set as GM_ORIGIN

string IP
IP address to send by default

unsigned short port
Port to send by default

methods

unsigned long ConvertToNumericIP(char *addr)
string -> long representation

Err WriteMsgToSocket(int sock, GMessage *msg)
Feed the raw data to socket

methods

Sender(LogFile * senderLogFile, Killer * killer, MessageQueue * toSenderQueue, string origin, string IP = "", unsigned short port = 0)
Constructor

virtual ~Sender()
Destructor

void* Run(void *)
Main thread function

Err DispatchMsg(GMessage *msg)
Take care of this one message

void DispatcherThread(GMessage *msg)
method that runs in a separate thread and sends the message

virtual void Shutdown()
Prepare for clean shutdown

GMessage* MakeMessageForSendingToMix(GMessage *chunk)
Insert default address and port to recipient

unsigned long Sender::ConvertToNumericIP(char *addr)
Converts string address into the unsigned long. In the Path field in msg we can have both DNS or IP addresses. Both types are as a *string*. We need to convert the address to an unsigned long.
Returns:
IP address represented by a long value.
Parameters:
addr - String representation of address (IP or hostname)
Author:
Pechy
See Also:
SenderDispatcher()

Err Sender::DispatchMsg(GMessage *msg)
Send a message over the network. Sender requested for sending a message - This method creates a thread, that should do all the work. It takes GM_RECIPIENT and sends the message to the address specified in it and just before it he inserts GM_RECIPIENT into the GM_CHUNK.
Returns:
OK if message was sent successfully.
Parameters:
msg - GMessage to send.
GM_RECIPIENT
GM_DDADDRESS
GM_PORT
GM_CHUNK

Author:
Pechy
See Also:
SenderDispatcherThread()

void Sender::DispatcherThread(GMessage *msg)
Connect to one of the recipients and send him the message. In our implementation, we use threads for despatching msgs. This method is the body of that thread. It expects:
GM_RECIPIENT_1
GM_ADDRESS
GM_PORT
[GM_RECIPIENT_2
GM_ADDRESS
GM_PORT     ]
GM_CHUNK
The chosen recipient is inserted into the GM_CHUNK and that is transmitted over network.
Returns:
void
Parameters:
msg - Message to send
Author:
Pechy
See Also:
Sender

GMessage* Sender::MakeMessageForSendingToMix(GMessage *chunk)
Add recipient to message. Gets chunk and adds to it the GM_RECIPIENT field so that sender knows how to deliver it and where.
Returns:
GMessage containing the original message with added GM_RECIPIENT field.
GM_RECIPIENT
GM_DDADDRESS
GM_PORT
GM_CHUNK
Parameters:
chunk - Message we want to send to Mix.
Author:
Pechy
See Also:
SenderDispatcherThread()

void* Sender::Run(void *)
Generic Sender Run() method. Neverending cycle, in each loop just one message passed from Padder is read and the method DispatchMsg() is called. This method should send message to the apropriate destination. Now DispatchMsg() creates thread for serving this.
Returns:
never
Author:
Pechy
See Also:
DispatchMsg()

Sender::Sender(LogFile * senderLogFile, Killer * killer, MessageQueue * toSenderQueue, string origin, string IP = "", unsigned short port = 0)
Generic sender constructor. Remembers all the parameters for future use and initializes its parent classes.
Parameters:
senderLogFile - Log file for debug messages.
killer - Who will notify us about shutdown.
origin - What will we insert as GM_ORIGIN into outgoing messages.
IP - Where to send messages by default (used when sending from Six to underlying Mix).
port - Port number to which to connect.
Author:
Pechy
See Also:
Receiver, Mix

void Sender::Shutdown()
Prepare for clean shutdown. This method should implement all the tasks necessary for preparation for a clean shutdown like saving inconsistent data to disk etc. Now it is empty as AddressManger is completely stateless as it stores certificate to disk immediatelly after it is generated.
Author:
Venca
See Also:
Shutdownable, Killer

Err Sender::WriteMsgToSocket(int sock, GMessage *msg)
Write message to connected socket. Writes body of the message to the socket, the socket must be already created and connected. This method is called from the thread is managing the actual sending.
Returns:
OK if successful else KO.
Parameters:
sock - Socket to write to.
msg - GMessage to send.
Author:
Pechy
See Also:
SenderDispatcher()

Sender::~Sender()
Generic Sender destructor. Empty by now.
Author:
Pechy
See Also:
Sender()


This class has no child classes.
Author:
Pechy
See Also:
Receiver

alphabetic index hierarchy of classes


generated by doc++