mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-26 23:13:13 +02:00
- libeventserver: formatting code using astyle
This commit is contained in:
@@ -40,8 +40,8 @@ void CEventServer::registerEvent(const int fd)
|
|||||||
{
|
{
|
||||||
commandRegisterEvent msg;
|
commandRegisterEvent msg;
|
||||||
|
|
||||||
int readresult= read(fd, &msg, sizeof(msg));
|
int readresult = read(fd, &msg, sizeof(msg));
|
||||||
if ( readresult<= 0 )
|
if (readresult <= 0)
|
||||||
perror("[eventserver]: read");
|
perror("[eventserver]: read");
|
||||||
// printf("[eventserver]: read from %d %x bytes %d/%d\n", fd, errno, readresult, sizeof(msg));
|
// printf("[eventserver]: read from %d %x bytes %d/%d\n", fd, errno, readresult, sizeof(msg));
|
||||||
// printf("[eventserver]: registered event (%d) to: %d - %s\n", msg.eventID, msg.clientID, msg.udsName);
|
// printf("[eventserver]: registered event (%d) to: %d - %s\n", msg.eventID, msg.clientID, msg.udsName);
|
||||||
@@ -50,7 +50,7 @@ void CEventServer::registerEvent(const int fd)
|
|||||||
|
|
||||||
void CEventServer::unRegisterEvent2(const unsigned int eventID, const unsigned int ClientID)
|
void CEventServer::unRegisterEvent2(const unsigned int eventID, const unsigned int ClientID)
|
||||||
{
|
{
|
||||||
eventData[eventID].erase( ClientID );
|
eventData[eventID].erase(ClientID);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEventServer::unRegisterEvent(const int fd)
|
void CEventServer::unRegisterEvent(const int fd)
|
||||||
@@ -60,11 +60,11 @@ void CEventServer::unRegisterEvent(const int fd)
|
|||||||
unRegisterEvent2(msg.eventID, msg.clientID);
|
unRegisterEvent2(msg.eventID, msg.clientID);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEventServer::sendEvent(const unsigned int eventID, const initiators initiatorID, const void* eventbody, const unsigned int eventbodysize)
|
void CEventServer::sendEvent(const unsigned int eventID, const initiators initiatorID, const void *eventbody, const unsigned int eventbodysize)
|
||||||
{
|
{
|
||||||
eventClientMap notifyClients = eventData[eventID];
|
eventClientMap notifyClients = eventData[eventID];
|
||||||
|
|
||||||
for(eventClientMap::iterator pos = notifyClients.begin(); pos != notifyClients.end(); ++pos)
|
for (eventClientMap::iterator pos = notifyClients.begin(); pos != notifyClients.end(); ++pos)
|
||||||
{
|
{
|
||||||
//allen clients ein event schicken
|
//allen clients ein event schicken
|
||||||
eventClient client = pos->second;
|
eventClient client = pos->second;
|
||||||
@@ -73,7 +73,7 @@ void CEventServer::sendEvent(const unsigned int eventID, const initiators initia
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CEventServer::sendEvent2Client(const unsigned int eventID, const initiators initiatorID, const eventClient* ClientData, const void* eventbody, const unsigned int eventbodysize)
|
bool CEventServer::sendEvent2Client(const unsigned int eventID, const initiators initiatorID, const eventClient *ClientData, const void *eventbody, const unsigned int eventbodysize)
|
||||||
{
|
{
|
||||||
struct sockaddr_un servaddr;
|
struct sockaddr_un servaddr;
|
||||||
int clilen, sock_fd;
|
int clilen, sock_fd;
|
||||||
@@ -89,7 +89,7 @@ bool CEventServer::sendEvent2Client(const unsigned int eventID, const initiators
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(connect(sock_fd, (struct sockaddr*) &servaddr, clilen) <0 )
|
if (connect(sock_fd, (struct sockaddr *) &servaddr, clilen) < 0)
|
||||||
{
|
{
|
||||||
char errmsg[128];
|
char errmsg[128];
|
||||||
snprintf(errmsg, 128, "[eventserver]: connect (%s)", ClientData->udsName);
|
snprintf(errmsg, 128, "[eventserver]: connect (%s)", ClientData->udsName);
|
||||||
@@ -106,7 +106,7 @@ bool CEventServer::sendEvent2Client(const unsigned int eventID, const initiators
|
|||||||
ssize_t ignored __attribute__((unused)) = write(sock_fd, &head, sizeof(head));
|
ssize_t ignored __attribute__((unused)) = write(sock_fd, &head, sizeof(head));
|
||||||
// printf ("[eventserver]: sent 0x%x - following eventbody= %d\n", written, eventbodysize );
|
// printf ("[eventserver]: sent 0x%x - following eventbody= %d\n", written, eventbodysize );
|
||||||
|
|
||||||
if(eventbodysize!=0)
|
if (eventbodysize != 0)
|
||||||
{
|
{
|
||||||
/*written = */
|
/*written = */
|
||||||
ignored = write(sock_fd, eventbody, eventbodysize);
|
ignored = write(sock_fd, eventbody, eventbodysize);
|
||||||
|
@@ -34,9 +34,9 @@
|
|||||||
|
|
||||||
class CEventServer
|
class CEventServer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum initiators
|
enum initiators
|
||||||
{
|
{
|
||||||
INITID_CONTROLD,
|
INITID_CONTROLD,
|
||||||
INITID_SECTIONSD,
|
INITID_SECTIONSD,
|
||||||
@@ -48,46 +48,46 @@ class CEventServer
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct commandRegisterEvent
|
struct commandRegisterEvent
|
||||||
{
|
{
|
||||||
unsigned int eventID;
|
unsigned int eventID;
|
||||||
unsigned int clientID;
|
unsigned int clientID;
|
||||||
char udsName[50];
|
char udsName[50];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct commandUnRegisterEvent
|
struct commandUnRegisterEvent
|
||||||
{
|
{
|
||||||
unsigned int eventID;
|
unsigned int eventID;
|
||||||
unsigned int clientID;
|
unsigned int clientID;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct eventHead
|
struct eventHead
|
||||||
{
|
{
|
||||||
unsigned int eventID;
|
unsigned int eventID;
|
||||||
unsigned int initiatorID;
|
unsigned int initiatorID;
|
||||||
unsigned int dataSize;
|
unsigned int dataSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
void registerEvent2(const unsigned int eventID, const unsigned int ClientID, const std::string &udsName);
|
void registerEvent2(const unsigned int eventID, const unsigned int ClientID, const std::string &udsName);
|
||||||
void registerEvent(const int fd);
|
void registerEvent(const int fd);
|
||||||
void unRegisterEvent2(const unsigned int eventID, const unsigned int ClientID);
|
void unRegisterEvent2(const unsigned int eventID, const unsigned int ClientID);
|
||||||
void unRegisterEvent(const int fd);
|
void unRegisterEvent(const int fd);
|
||||||
void sendEvent(const unsigned int eventID, const initiators initiatorID, const void* eventbody = NULL, const unsigned int eventbodysize = 0);
|
void sendEvent(const unsigned int eventID, const initiators initiatorID, const void *eventbody = NULL, const unsigned int eventbodysize = 0);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
struct eventClient
|
struct eventClient
|
||||||
{
|
{
|
||||||
char udsName[50];
|
char udsName[50];
|
||||||
};
|
};
|
||||||
|
|
||||||
//key: ClientID // Map is a Sorted Associative Container
|
//key: ClientID // Map is a Sorted Associative Container
|
||||||
typedef std::map<unsigned int, eventClient> eventClientMap; // -> clients with lower ClientID receive events first
|
typedef std::map<unsigned int, eventClient> eventClientMap; // -> clients with lower ClientID receive events first
|
||||||
|
|
||||||
//key: eventID
|
//key: eventID
|
||||||
std::map<unsigned int, eventClientMap> eventData;
|
std::map<unsigned int, eventClientMap> eventData;
|
||||||
|
|
||||||
bool sendEvent2Client(const unsigned int eventID, const initiators initiatorID, const eventClient* ClientData, const void* eventbody = NULL, const unsigned int eventbodysize = 0);
|
bool sendEvent2Client(const unsigned int eventID, const initiators initiatorID, const eventClient *ClientData, const void *eventbody = NULL, const unsigned int eventbodysize = 0);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user