// // NotificationService.cpp // App // // Created by Ganesh Agrawal on 5/15/14. // // #include "stdafx.h" #include "V8DataModel/NotificationService.h" #include "V8DataModel/UserInputService.h" #include "Network/Players.h" FASTFLAGVARIABLE(NotificationServiceEnabledForEveryone, false); namespace RBX { const char* const sNotificationService = "NotificationService"; REFLECTION_BEGIN(); static Reflection::BoundFuncDesc func_ScheduleNotification( &NotificationService::scheduleNotification, "ScheduleNotification", "userId", "alertId", "alertMsg", "minutesToFire", Security::RobloxPlace); static Reflection::BoundFuncDesc func_CancelNotification( &NotificationService::cancelNotification, "CancelNotification", "userId", "alertId", Security::RobloxPlace); static Reflection::BoundFuncDesc func_CancelAllNotification( &NotificationService::cancelAllNotification, "CancelAllNotification", "userId", Security::RobloxPlace); static Reflection::BoundYieldFuncDesc(int)> func_GetScheduledNotifications( &NotificationService::getScheduledNotifications, "GetScheduledNotifications", "userId", Security::RobloxPlace); REFLECTION_END(); NotificationService::NotificationService() { setName(sNotificationService); } bool NotificationService::canUseService() { bool retVal = true; if (!FFlag::NotificationServiceEnabledForEveryone) { StandardOut::singleton()->printf(MESSAGE_WARNING, "Sorry, NotificationService is currently off."); retVal = false; } if (RBX::UserInputService* inputService = RBX::ServiceProvider::find(this)) { if (!inputService->getTouchEnabled()) { StandardOut::singleton()->printf(MESSAGE_WARNING, "Sorry, NotificationService only works on touch devices currently."); retVal = false; } } if (!Network::Players::frontendProcessing(this)) { StandardOut::singleton()->printf(MESSAGE_WARNING, "NotificationService:ScheduleNotification must be called from a local script!"); retVal = false; } return retVal; } void NotificationService::scheduleNotification(int userId, int alertId, std::string alerMsg, int minutesToFire) { if (canUseService()) scheduleNotificationSignal(userId, alertId, alerMsg, minutesToFire); } void NotificationService::cancelNotification(int userId, int alertId) { if (canUseService()) cancelNotificationSignal(userId, alertId); } void NotificationService::cancelAllNotification(int userId) { if (canUseService()) cancelAllNotificationSignal(userId); } void NotificationService::getScheduledNotifications(int userId, boost::function)> resumeFunction, boost::function errorFunction) { if (canUseService()) getScheduledNotificationsSignal(userId, resumeFunction, errorFunction); else errorFunction("Notification Service Not Available"); } }// namespace RBX