From b035321def62e46982cd6d5d81d4284e894f6c3a Mon Sep 17 00:00:00 2001 From: lasantha Date: Sat, 5 Aug 2017 07:24:15 +0530 Subject: [PATCH] fixes wso2/product-iots/#1266 --- .../public/js/device-stats.js | 4 ++-- .../android/services/impl/EventReceiverServiceImpl.java | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/public/js/device-stats.js b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/public/js/device-stats.js index c7a08f93b..1489e9cd8 100644 --- a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/public/js/device-stats.js +++ b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/public/js/device-stats.js @@ -73,9 +73,9 @@ $(window).load(function () { connect(websocketUrl) }); -$(window).unload(function () { +window.onbeforeunload = function() { disconnect(); -}); +}; //websocket connection function connect(target) { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/EventReceiverServiceImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/EventReceiverServiceImpl.java index bfee9eeb6..594ee9dac 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/EventReceiverServiceImpl.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/EventReceiverServiceImpl.java @@ -73,13 +73,13 @@ public class EventReceiverServiceImpl implements EventReceiverService { String eventPayload = eventBeanWrapper.getPayload(); JsonObject jsonObject = gson.fromJson(eventPayload, JsonObject.class); Object payload[] = { - jsonObject.get(TIME_STAMP), - jsonObject.get(LONGITUDE), - jsonObject.get(LATITUDE) + jsonObject.get(TIME_STAMP).getAsLong(), + jsonObject.get(LONGITUDE).getAsDouble(), + jsonObject.get(LATITUDE).getAsDouble() }; try { if (AndroidAPIUtils.getEventPublisherService().publishEvent( - EVENT_STREAM_DEFINITION, "1.0.0", new Object[0], new Object[0], payload)) { + EVENT_STREAM_DEFINITION, "1.0.0", metaData, new Object[0], payload)) { message.setResponseCode("Event is published successfully."); return Response.status(Response.Status.CREATED).entity(message).build(); } else {