private void RegisterNotification() { // Storing a delegate in class field is necessary to prevent garbage collector from collecting // the delegate before it is called. Otherwise, CallbackOnCollectedDelegate may occur. _notificationCallback = new WLAN_NOTIFICATION_CALLBACK((data, context) => { var notificationData = Marshal.PtrToStructure <WLAN_NOTIFICATION_DATA>(data); if (notificationData.NotificationSource != WLAN_NOTIFICATION_SOURCE_ACM) { return; } NotificationReceived?.Invoke(null, notificationData); }); var result = WlanRegisterNotification( Handle, WLAN_NOTIFICATION_SOURCE_ACM, false, _notificationCallback, IntPtr.Zero, IntPtr.Zero, 0); CheckResult(nameof(WlanRegisterNotification), result, true); }
private async Task<DeviceInstallation> GenerateInstallation(string groupName = null) { App.Channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync(); App.Channel.PushNotificationReceived += (s, e) => { NotificationReceived?.Invoke(s, e); }; string installationId = null; if (!ApplicationData.Current.LocalSettings.Values.ContainsKey("nhInstallationID")) { installationId = Guid.NewGuid().ToString(); ApplicationData.Current.LocalSettings.Values.Add("nhInstallationID", installationId); } else installationId = (string)ApplicationData.Current.LocalSettings.Values["nhInstallationID"]; string userTag = $"{App.User.SID}"; string deviceTag = $"{installationId}"; //string userTag = "testtag"; var deviceInstallation = new DeviceInstallation { InstallationId = installationId, Platform = "wns", PushChannel = App.Channel.Uri, Tags = groupName == null ? new string[] { userTag, deviceTag } : new string[] { userTag, deviceTag, groupName } }; App.DeviceInstallation = deviceInstallation; return deviceInstallation; }
/// <summary> /// Fired when a notification was received /// </summary> /// <param name="e"></param> /// <returns></returns> public async Task OnNotificationAsync(NotificationReceivedEventArgs e) { if (NotificationReceived != null) { await NotificationReceived.Invoke(e); } }
public TileInfo(string App) { notificationTimer = new Timer(5000); Name = "App Name (TEMP)"; //Get App name here Icon = new ImageBrush(); //Get App icon here Color = Color.FromArgb(0xFF, 0xFF, 0, 0xFF); //Get App color here //"Microsoft.BingSports_3.0.4.212_x64__8wekyb3d8bbwe" CurrentNotification = AppxTools.GetLiveTileNotification(AppxTools.GetUpdateAddressFromApp(App)); UIElement element = new UIElement(); notificationTimer.Elapsed += delegate { element.Dispatcher.Invoke(new Action(() => { var NewNotification = AppxTools.GetLiveTileNotification(AppxTools.GetUpdateAddressFromApp(App)); if (CurrentNotification != NewNotification) { NotificationReceived?.Invoke(this, new NotificationInfoEventArgs() { OldNotification = CurrentNotification, NewNotification = NewNotification }); CurrentNotification = NewNotification; } })); }; notificationTimer.Start(); }
private void Client_NotificationReceived(object sender, JsonRpcNotificationEventArgs e) { if (e.Notification.Method == Methods.Log) { var logMessage = e.Notification.GetParams <LogMessage>(); switch (logMessage.level) { case LogLevel.debug: logger.Debug("Butler: " + logMessage.message); break; case LogLevel.info: logger.Info("Butler: " + logMessage.message); break; case LogLevel.warning: logger.Warn("Butler: " + logMessage.message); break; case LogLevel.error: logger.Error("Butler: " + logMessage.message); break; } } NotificationReceived?.Invoke(this, e); }
private void ConnectSocket(string uri) { WebSocket = new WebSocket(uri); WebSocket.SslConfiguration.EnabledSslProtocols = System.Security.Authentication.SslProtocols.Tls12; WebSocket.OnMessage += (sender, e) => { try { var data = JsonConvert.DeserializeObject <NotificationData <JObject> >(e.Data); if (!_typeMap.ContainsKey(data.TopicName.ToLowerInvariant())) { return; } var genericNotificationType = typeof(NotificationData <>); var specificNotificationType = genericNotificationType.MakeGenericType(_typeMap[data.TopicName.ToLowerInvariant()]); var notification = JsonConvert.DeserializeObject(e.Data, specificNotificationType); if (notification == null) { return; } NotificationReceived?.Invoke((INotificationData)notification); } catch (Exception ex) { Console.WriteLine(ex); } }; WebSocket.Connect(); }
public void Notify(string txt, SimulationEventNotificationPriority prio = SimulationEventNotificationPriority.Normal) { DateTime timestamp = GameTimeComponent.CurrentTime; SimulationEventNotification newNotification = new SimulationEventNotification(txt, prio, timestamp); NotificationReceived?.Invoke(newNotification); }
/// <summary> /// Receives incoming notifications and informs any subscribers. /// </summary> private void NotificationProcessingThread() { while (!_isDisposed) { Thread.Sleep(1); // only bother if it's been fully converted, otherwise it will gobble up the initial status response if (NotificationSession == null || !NotificationSession.Options.HasFlag(XboxConnectionOptions.NotificationSession)) { continue; } // look for a new notification string notification = NotificationSession?.TryReceiveLine(); if (notification == null) { continue; } // save for later Logger?.Debug($"Notification received: {notification}"); NotificationHistory.Enqueue(notification); // start dequeuing old entries if greater than max history count if (NotificationHistory.Count > MaxNotificationHistoryCount) { string garbage; NotificationHistory.TryDequeue(out garbage); } // inform any subscribers NotificationReceived?.Invoke(this, new XboxNotificationEventArgs(notification)); } }
/// <inheritdoc /> public void Notify(INotification notification) { NotificationReceived?.Invoke(this, notification); var popup = new NotificationPopupViewModel(notification); popup.Closed += e => { Notifications.Remove(e); }; var timer = new Timer(_notificationDuration); timer.Elapsed += delegate { ExecuteOnUIContext(() => { popup.Close(); timer.Stop(); timer.Dispose(); }); }; timer.Start(); GC.KeepAlive(timer); Notifications.Add(popup); }
private void DataReceived(string data) { var request = Serialization.FromJson <RpcMessage>(data); if (request.Id != null && string.IsNullOrEmpty(request.Method)) { // Response requestResponses.TryAdd(request.Id.Value, data); } else if (request.Id != null && !string.IsNullOrEmpty(request.Method)) { // Request RequestReceived?.Invoke(this, new JsonRpcRequestEventArgs() { Request = Serialization.FromJson <JsonRpcRequest>(data) }); } else if (request.Id == null) { // Notification NotificationReceived?.Invoke(this, new JsonRpcNotificationEventArgs() { Notification = Serialization.FromJson <JsonRpcNotification>(data) }); } else { logger.Error("Recevied invalid RPC message:"); logger.Error(data); } }
public void Activate(string appUserModelId, string invokedArgs, NOTIFICATION_USER_INPUT_DATA[] data, uint dataCount) { var keyValuePairs = Enumerable.Range(0, (int)dataCount) .ToDictionary(i => data[i].Key, i => data[i].Value); NotificationReceived?.Invoke(this, new NotificationReceivedEventArgs(invokedArgs, keyValuePairs)); }
public void ReceiveNotification(string title, string message) { NotificationReceived?.Invoke(null, new NotificationEventArgs() { Title = title, Message = message }); }
private void Characteristic_ValueChanged(GattCharacteristic sender, GattValueChangedEventArgs args) { if (sender == notificationCharacteristic) { Debug.WriteLine($"Received notification of data to Bluetooth LE characteristic."); NotificationReceived?.Invoke(this, new NotifyEventArgs(args.CharacteristicValue.ToArray())); } }
public void ReceiveNotification(NotificationInfo info) { var args = new NotificationEventArgs() { Info = info }; NotificationReceived?.Invoke(null, args); }
public void ReceiveNotification(string title, string message) { var args = new NotificationEventArgs() { Title = title, Message = message, }; NotificationReceived?.Invoke(null, args); }
public void ReceiveNotification(string resourceName) { var args = new NotificationEventArgs() { ResourceName = resourceName, }; NotificationReceived?.Invoke(null, args); }
public void ReceiveNotification(string title, string message) { //var args = new NotificationEventArgs() //{ // Title = title, // Message = message, //}; NotificationReceived?.Invoke(null, null); }
public Task RaiseMessage(NotificationType notificationType, MarkupString message, string title = null, Action <NotificationOptions> options = null) { var notificationOptions = NotificationOptions.Default; options?.Invoke(notificationOptions); NotificationReceived?.Invoke(this, new(notificationType, message, title, notificationOptions) ); return(Task.CompletedTask); }
public Task Error(string message, string title = null, Action <UiNotificationOptions> options = null) { var uiNotificationOptions = CreateDefaultOptions(); options?.Invoke(uiNotificationOptions); NotificationReceived?.Invoke(this, new UiNotificationEventArgs(UiNotificationType.Error, message, title, uiNotificationOptions)); return(Task.CompletedTask); }
public static void StartListening() { var queryString = new Dictionary <string, string>() { { "token", ApiToken } }; _connection = new HubConnection("https://stormaio.net/", queryString); _hubProxy = _connection.CreateHubProxy("BiipApi"); _hubProxy.On <Product>("ProductUpdated", product => NotificationReceived?.Invoke(product)); _connection.Start(); }
public void ReceiveNotification(string title, string description, string authReqId, ICollection <NotificationPermission> permissions) { var args = new NotificationEventArgs() { Title = title, Description = description, AuthReqId = authReqId, Permissions = permissions }; NotificationReceived?.Invoke(null, args); }
public void ReceiveNotification(string title, string message, bool isValid) { if (isValid) { var args = new NotificationEventArgs() { Title = title.Substring(21), Message = message }; NotificationReceived?.Invoke(null, args); } }
public void DelegarAccionDeNotificacion(MensajeSocio mensaje) { NotificationReceived?.Invoke(this, mensaje); var paginaSolicitarServicio = typeof(SolicitarServicio); var paginaActual = App.Current.MainPage.Navigation.NavigationStack[App.Current.MainPage.Navigation.NavigationStack.Count - 1]; if (paginaActual.GetType() == paginaSolicitarServicio) { var dtx = paginaActual.BindingContext as Core.Lib.ViewModels.Socios.SolicitarServicioViewModel; var servicio = new SolicitudServicio { Mensaje = mensaje.MensajePrincipal, ClaveTipoServicio = mensaje.ClaveTipoServicio, FechaSolicitud = mensaje.FechaSolicitud, FolioSolicitud = mensaje.FolioSolicitud, IdCliente = mensaje.IdCliente, IdSolicitud = mensaje.IdSolicitud, IdTipoSolicitud = mensaje.IdTipoSolicitud, NombreCliente = mensaje.NombreCliente, NombreServicio = mensaje.NombreServicio, TipoServicio = mensaje.TipoServicio, Ubicacion = mensaje.Ubicacion, TipoNotificacion = mensaje.TipoNotificacion }; if (mensaje.TipoNotificacion.Equals((int)TipoNotificacionEnum.ClienteSolicita)) { dtx.MostrarModalSolicitudCommand.Execute(servicio); } else if (mensaje.TipoNotificacion.Equals((int)TipoNotificacionEnum.Alerta)) { dtx.AbrirModalAlertaCommand.Execute(mensaje.MensajePrincipal); } } else { MPS.Core.Lib.Helpers.Settings.Current.Solicitud = new SharedAPIModel.Socios.SolicitudServicio { Mensaje = mensaje.MensajePrincipal, ClaveTipoServicio = mensaje.ClaveTipoServicio, FechaSolicitud = mensaje.FechaSolicitud, FolioSolicitud = mensaje.FolioSolicitud, IdCliente = mensaje.IdCliente, IdSolicitud = mensaje.IdSolicitud, IdTipoSolicitud = mensaje.IdTipoSolicitud, NombreCliente = mensaje.NombreCliente, NombreServicio = mensaje.NombreServicio, TipoServicio = mensaje.TipoServicio, Ubicacion = mensaje.Ubicacion, TipoNotificacion = mensaje.TipoNotificacion }; } }
public void NotifyError(string message) { var notification = new Notification { At = DateTime.Now, Id = 0, Code = 0, Message = message, NotificationType = NotificationType.Error }; NotificationReceived?.Invoke(this, notification); }
public void error(int id, int code, string errorMsg) { var notification = new Notification { At = DateTime.Now, Id = id, Code = code, Message = errorMsg, NotificationType = errorMsg.ToUpper().Contains("ERROR")? NotificationType.Error : NotificationType.Information }; NotificationReceived?.Invoke(this, notification); }
public void error(Exception e) { var notification = new Notification { At = DateTime.Now, Id = 0, Code = 0, Message = e.Message, NotificationType = NotificationType.Error }; NotificationReceived?.Invoke(this, notification); }
public void ReceiveNotification(ItemTranslation itemTranslation) { var args = new NotificationEventArgs() { Title = itemTranslation.German, Message = itemTranslation.English, }; NotificationReceived?.Invoke(null, args); var historyDatabaseController = new HistoryDatabaseController(); historyDatabaseController.SaveToHistory(itemTranslation); }
public void ReceiveNotification(string title, string message) { JObject o = JObject.Parse(message); var args = new NotificationEventArgs() { SwapId = long.Parse(o["swapId"].ToString()), Currency = o["currency"].ToString(), TxId = o["txId"].ToString(), PushType = o["type"].ToString() }; NotificationReceived?.Invoke(null, args); }
private void _HandleNotification(NotificationMessage message) { Debug("Handle Notification", message); if (message.Method.Equals(CoreMethods.Exit)) { Stop(); Exit?.Invoke(this, new EventArgs()); } else { NotificationReceived?.Invoke(this, message); } }
public void ReceiveNotification(string title, string message) { try { var args = new NotificationEventArgs() { Title = title, Message = message, }; NotificationReceived?.Invoke(null, args); } catch (Exception e) { //Crashes.TrackError(e); } }