public AJ_Status CancelNotification(UInt32 busAttachment, UInt32 serialNum) { AJ_Status status; UInt32 messageType = 0; if (serialNum == 0) { return(AJ_Status.AJ_OK); } for (; messageType < AJNS_NUM_MESSAGE_TYPES; messageType++) { if (LastSentNotifications[messageType].serialNum == serialNum) { break; } } if (messageType >= AJNS_NUM_MESSAGE_TYPES) { return(AJ_Status.AJ_OK); } status = AjInst.BusCancelSessionless(busAttachment, serialNum); if (status != AJ_Status.AJ_OK) { return(status); } LastSentNotifications[messageType].notificationId = 0; LastSentNotifications[messageType].serialNum = 0; return(status); }
AJ_Status DeleteLastNotification(UInt32 busAttachment, UInt16 messageType) { AJ_Status status; UInt32 lastSentSerialNumber; if (messageType >= AJNS_NUM_MESSAGE_TYPES) { return(AJ_Status.AJ_ERR_DISALLOWED); } lastSentSerialNumber = LastSentNotifications[messageType].serialNum; if (lastSentSerialNumber == 0) { return(AJ_Status.AJ_OK); } status = AjInst.BusCancelSessionless(busAttachment, lastSentSerialNumber); if (status != AJ_Status.AJ_OK) { return(status); } LastSentNotifications[messageType].notificationId = 0; LastSentNotifications[messageType].serialNum = 0; return(status); }
public AJ_Status SendNotification(UInt32 bus, string message, UInt16 messageType, UInt32 ttl, ref UInt32 messageSerialNumber) { AJ_Status status; AJNS_Notification notification = new AJNS_Notification(); notification.version = AJNS_NotificationVersion; if (messageType >= AJNS_NUM_MESSAGE_TYPES) { return(AJ_Status.AJ_ERR_DISALLOWED); } notification.messageType = messageType; if ((ttl < AJNS_NOTIFICATION_TTL_MIN) || (ttl > AJNS_NOTIFICATION_TTL_MAX)) //ttl is mandatory and must be in range { return(AJ_Status.AJ_ERR_DISALLOWED); } notification.deviceId = propertyStore.GetValue((int)PropertyStoreFieldIndices.AJSVC_PROPERTY_STORE_DEVICE_ID); notification.deviceName = propertyStore.GetValueForLang((int)PropertyStoreFieldIndices.AJSVC_PROPERTY_STORE_DEVICE_NAME, propertyStore.GetLanguageIndex("")); notification.appId = propertyStore.GetValue((int)PropertyStoreFieldIndices.AJSVC_PROPERTY_STORE_APP_ID); notification.appName = propertyStore.GetValue((int)PropertyStoreFieldIndices.AJSVC_PROPERTY_STORE_APP_NAME); if ((IsNullOrEmpty(notification.deviceId)) || (IsNullOrEmpty(notification.deviceName)) || (IsNullOrEmpty(notification.appId)) || (IsNullOrEmpty(notification.appName))) { return(AJ_Status.AJ_ERR_DISALLOWED); } if (notification.version > 1) { notification.originalSenderName = AjInst.GetUniqueName(bus); if (IsNullOrEmpty(notification.originalSenderName)) { return(AJ_Status.AJ_ERR_DISALLOWED); } } else { notification.originalSenderName = String.Empty; } if (NotificationId == 0) { //NotificationId = GetGUID(); } notification.notificationId = NotificationId; UInt32 serialNumber = 0; status = SendNotifySignal(bus, notification, ttl, message, ref serialNumber); if (status == AJ_Status.AJ_OK) { LastSentNotifications[messageType].notificationId = NotificationId++; LastSentNotifications[messageType].serialNum = serialNumber; messageSerialNumber = serialNumber; } return(status); }