示例#1
0
 public AppContext(CommModule commInstance, StreamWebSocket webSocket, ControlChannelTrigger channel, string id)
 {
     WebSocketHandle = webSocket;
     Channel         = channel;
     ChannelId       = id;
     CommInstance    = commInstance;
     messageQueue    = new ConcurrentQueue <Message>();
 }
示例#2
0
        public void Run(IBackgroundTaskInstance taskInstance)
        {
            if (taskInstance == null)
            {
                Diag.DebugPrint("NetworkChangeTask: taskInstance was null");
                return;
            }

            string channelId = "notifications";

            if (CoreApplication.Properties.ContainsKey(channelId))
            {
                try
                {
                    var appContext = CoreApplication.Properties[channelId] as AppContext;

                    if (appContext != null && appContext.CommInstance != null)
                    {
                        CommModule commInstance = appContext.CommInstance;

                        commInstance.Reset();
                        commInstance.SetupTransport(commInstance.socketUri);
                    }
                }
                catch (Exception ex)
                {
                    Diag.DebugPrint("Registering with the RTC broker failed with: " + ex.Message);
                }
            }
            else
            {
                Diag.DebugPrint("Cannot find AppContext key for Notifications");
            }

            Diag.DebugPrint("System Task - " + taskInstance.Task.Name + " finished");
        }