From aa83ca05d35edbba7784909ee09da1980b9fe450 Mon Sep 17 00:00:00 2001 From: thlo Date: Sat, 11 May 2013 15:45:00 +0200 Subject: OsdStatusMessage added. --- httpclient.c | 16 ++++++++++++++++ httpclient.h | 12 +++++++++++- smarttvfactory.c | 21 ++++++++++++++++++++- smarttvfactory.h | 1 + 4 files changed, 48 insertions(+), 2 deletions(-) diff --git a/httpclient.c b/httpclient.c index f1dd793..a3fb192 100644 --- a/httpclient.c +++ b/httpclient.c @@ -389,3 +389,19 @@ cHttpInfoClient::~cHttpInfoClient() { string cHttpInfoClient::getMsgBody(int) { return "{\"type\":\"INFO\",payload:" + mBody +"}";; } + + +//-------------------------------- +//----- cHttpMesgPushClient ------ +//-------------------------------- +cHttpMesgPushClient::cHttpMesgPushClient(int f, int id, int port, SmartTvServer* fac, string peer, string mesg) : cHttpClientBase(f, id, port, fac, peer), mMesg(mesg) { + + createRequestMessage(""); +} + +cHttpMesgPushClient::~cHttpMesgPushClient() { +} + +string cHttpMesgPushClient::getMsgBody(int) { + return "{\"type\":\"MESG\",payload:" + mMesg +"}";; +} diff --git a/httpclient.h b/httpclient.h index 000eaa8..d30528e 100644 --- a/httpclient.h +++ b/httpclient.h @@ -105,8 +105,18 @@ class cHttpInfoClient : public cHttpClientBase { protected: string getMsgBody(int ); - string mBody; }; +class cHttpMesgPushClient : public cHttpClientBase { + public: + cHttpMesgPushClient(int, int, int, SmartTvServer*, string peer, string mesg); + virtual ~cHttpMesgPushClient(); + + protected: + string getMsgBody(int ); + string mMesg; +}; + + #endif diff --git a/smarttvfactory.c b/smarttvfactory.c index f721658..763baeb 100755 --- a/smarttvfactory.c +++ b/smarttvfactory.c @@ -132,6 +132,7 @@ void SmartTvServer::Recording(const cDevice *Device, const char *Name, const cha } }; + void SmartTvServer::TimerChange(const cTimer *Timer, eTimerChange Change) { #ifndef DEBUG *(mLog.log()) << "SmartTvServer::TimerChange" @@ -181,6 +182,24 @@ void SmartTvServer::TimerChange(const cTimer *Timer, eTimerChange Change) { } } +void SmartTvServer::OsdStatusMessage(const char *Message) { + *(mLog.log()) << "SmartTvServer::OsdStatusMessage: Msg= " << ((Message != NULL) ? Message : "") << endl; + + if (Message == NULL) + return; + + string msg = Message; + + for (uint i = 0; i < mConTvClients.size(); i ++) { + if ((mConTvClients[i]->ip).compare("") != 0) { + int cfd= connectToClient(mConTvClients[i]->ip); + if (cfd < 0) + continue; + addHttpResource(cfd, new cHttpMesgPushClient(cfd, mHttpClientId, serverPort, this, mConTvClients[i]->ip, msg)); + } + } +} + void SmartTvServer::cleanUp() { // close listening ports for (uint idx= 0; idx < clientList.size(); idx++) { @@ -373,7 +392,7 @@ void SmartTvServer::threadLoop() { void SmartTvServer::loop() { socklen_t addr_size = 0; - int rfd; + unsigned int rfd; sockaddr_in sadr; int req_id = 0; int ret = 0; diff --git a/smarttvfactory.h b/smarttvfactory.h index c35d2f6..a225a65 100644 --- a/smarttvfactory.h +++ b/smarttvfactory.h @@ -97,6 +97,7 @@ class SmartTvServer : public cStatus { // status callbacks void Recording(const cDevice *Device, const char *Name, const char *FileName, bool On); void TimerChange(const cTimer *Timer, eTimerChange Change); + void OsdStatusMessage(const char *Message); pthread_t mThreadId; int mRequestCount; -- cgit v1.2.3