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); }
public extern AJ_Status SendNotifySignal(UInt32 bus, AJNS_Notification not, UInt32 ttl, string message, ref UInt32 serialNumber);