#include #include "macros.h" #include "lowsender.h" #define DEBUG 0 #define MESSAGE "AB or CB cast from LowSender ? hehe...." LowSender::LowSender(Group &grp, Clock &clk, Protocol::Type type) : _group(grp), _clock(clk), _type(type) { } void LowSender::run(){ // thread part srand(time(NULL)); while(1){ sleep(3); if (rand() % 3 == 0) { printf("LowSender::run -- Broadcasting '%s'\n", MESSAGE); TimeStamp ts = _clock.inc(); pDEBUG("Timestamp done\n"); Message msg(_type, ts, MESSAGE, strlen(MESSAGE)); pDEBUG("Mesg done and ready to send\n"); _group.broadcast(msg); pDEBUG("Mesg sent\n"); } else { pDEBUG("Not sending\n"); } } }