Use dynamic_cast instead of reinterpret_cast for our events
This commit is contained in:
parent
7b82e529cc
commit
39c6bb012e
2 changed files with 4 additions and 4 deletions
|
@ -58,7 +58,7 @@ void EventUpdateManager::run() {
|
||||||
if(d->clientConnectEvent->isSignaled()) {
|
if(d->clientConnectEvent->isSignaled()) {
|
||||||
// new client added
|
// new client added
|
||||||
TelldusCore::EventDataRef eventData = d->clientConnectEvent->takeSignal();
|
TelldusCore::EventDataRef eventData = d->clientConnectEvent->takeSignal();
|
||||||
ConnectionListenerEventData *data = reinterpret_cast<ConnectionListenerEventData*>(eventData.get());
|
ConnectionListenerEventData *data = dynamic_cast<ConnectionListenerEventData*>(eventData.get());
|
||||||
if(data) {
|
if(data) {
|
||||||
d->clients.push_back(data->socket);
|
d->clients.push_back(data->socket);
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,7 @@ void TelldusMain::start(void) {
|
||||||
if (clientEvent->isSignaled()) {
|
if (clientEvent->isSignaled()) {
|
||||||
// New client connection
|
// New client connection
|
||||||
TelldusCore::EventDataRef eventDataRef = clientEvent->takeSignal();
|
TelldusCore::EventDataRef eventDataRef = clientEvent->takeSignal();
|
||||||
ConnectionListenerEventData *data = reinterpret_cast<ConnectionListenerEventData*>(eventDataRef.get());
|
ConnectionListenerEventData *data = dynamic_cast<ConnectionListenerEventData*>(eventDataRef.get());
|
||||||
if (data) {
|
if (data) {
|
||||||
ClientCommunicationHandler *clientCommunication = new ClientCommunicationHandler(data->socket, handlerEvent, &deviceManager, deviceUpdateEvent, &controllerManager);
|
ClientCommunicationHandler *clientCommunication = new ClientCommunicationHandler(data->socket, handlerEvent, &deviceManager, deviceUpdateEvent, &controllerManager);
|
||||||
clientCommunication->start();
|
clientCommunication->start();
|
||||||
|
@ -106,7 +106,7 @@ void TelldusMain::start(void) {
|
||||||
|
|
||||||
if (d->controllerChangeEvent->isSignaled()) {
|
if (d->controllerChangeEvent->isSignaled()) {
|
||||||
TelldusCore::EventDataRef eventDataRef = d->controllerChangeEvent->takeSignal();
|
TelldusCore::EventDataRef eventDataRef = d->controllerChangeEvent->takeSignal();
|
||||||
ControllerChangeEventData *data = reinterpret_cast<ControllerChangeEventData*>(eventDataRef.get());
|
ControllerChangeEventData *data = dynamic_cast<ControllerChangeEventData*>(eventDataRef.get());
|
||||||
if (data) {
|
if (data) {
|
||||||
controllerManager.deviceInsertedOrRemoved(data->vid, data->pid, "", data->inserted);
|
controllerManager.deviceInsertedOrRemoved(data->vid, data->pid, "", data->inserted);
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ void TelldusMain::start(void) {
|
||||||
|
|
||||||
if (dataEvent->isSignaled()) {
|
if (dataEvent->isSignaled()) {
|
||||||
TelldusCore::EventDataRef eventData = dataEvent->takeSignal();
|
TelldusCore::EventDataRef eventData = dataEvent->takeSignal();
|
||||||
ControllerEventData *data = reinterpret_cast<ControllerEventData*>(eventData.get());
|
ControllerEventData *data = dynamic_cast<ControllerEventData*>(eventData.get());
|
||||||
if (data) {
|
if (data) {
|
||||||
deviceManager.handleControllerMessage(*data);
|
deviceManager.handleControllerMessage(*data);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue