Exemple #1
0
        public static async Task AcceptConnection(string serviceName, CommModule myCommModule)
        {
            // Create and store a streamsocketlistener in the class. This way, new connections
            // can be automatically accepted.
            if (myCommModule.serverListener == null)
            {
                myCommModule.serverListener = new StreamSocketListener();
            }

            myCommModule.serverListener.ConnectionReceived += (op, evt) =>
            {
                // For simplicity, the server can talk to only one client at a time.
                myCommModule.serverSocket = evt.Socket;
                if (myCommModule.writePacket != null)
                {
                    myCommModule.writePacket.DetachStream();
                    myCommModule.writePacket = null;
                }

                Diag.DebugPrint("Connection Received!");
            };
            await myCommModule.serverListener.BindServiceNameAsync(serviceName);

            return;
        }
Exemple #2
0
 public AppContext(CommModule commInstance, StreamSocket socket, ControlChannelTrigger channel, string id)
 {
     SocketHandle = socket;
     Channel      = channel;
     ChannelId    = id;
     CommInstance = commInstance;
     messageQueue = new ConcurrentQueue <string>();
 }
 public void Dispose()
 {
     if (commModule != null)
     {
         commModule.Dispose();
         commModule = null;
     }
 }
        async void ClientInit()
        {
            commModule = new CommModule(AppRole.ClientRole);

            // In the client role, we require the application to be on lock screen.
            // Lock screen is required to let in-process RealTimeCommunication related
            // background code to execute.
            if (lockScreenAdded == false)
            {
                BackgroundAccessStatus status = await BackgroundExecutionManager.RequestAccessAsync();
                Diag.DebugPrint("Lock screen status" + status);

                switch (status)
                {
                    case BackgroundAccessStatus.AllowedWithAlwaysOnRealTimeConnectivity:

                        // App is allowed to use RealTimeConnection broker 
                        // functionality even in low power mode.
                        lockScreenAdded = true;
                        break;
                    case BackgroundAccessStatus.AllowedMayUseActiveRealTimeConnectivity:

                        // App is allowed to use RealTimeConnection broker 
                        // functionality but not in low power mode.
                        lockScreenAdded = true;
                        break;
                    case BackgroundAccessStatus.Denied:

                        // App should switch to polling mode (example: poll for email based on time triggers)
                        Diag.DebugPrint("As Lockscreen status was Denied, App should switch to polling mode such as email based on time triggers.");
                        break;
                }
            }

            // Now, enable the client settings if the role hasn't changed.
            if (appRole == appRoles.clientRole)
            {
                ClientSettings.Visibility = Visibility.Visible;
            }
            ConnectButton.Visibility = Visibility.Visible;
            return;
        }
 void ServerInit()
 {
     commModule = new CommModule(AppRole.ServerRole);
 }
Exemple #6
0
 public AppContext(CommModule commInstance, StreamSocket socket, ControlChannelTrigger channel, string id)
 {
     SocketHandle = socket;
     Channel = channel;
     ChannelId = id;
     CommInstance = commInstance;
     messageQueue = new ConcurrentQueue<string>();
 }
Exemple #7
0
        public static async Task AcceptConnection(string serviceName, CommModule myCommModule)
        {

            // Create and store a streamsocketlistener in the class. This way, new connections
            // can be automatically accepted.
            if (myCommModule.serverListener == null)
            {
                myCommModule.serverListener = new StreamSocketListener();
            }

            myCommModule.serverListener.ConnectionReceived += (op, evt) =>
            {
                // For simplicity, the server can talk to only one client at a time.
                myCommModule.serverSocket = evt.Socket;
                if (myCommModule.writePacket != null)
                {
                    myCommModule.writePacket.DetachStream();
                    myCommModule.writePacket = null;
                }

                Diag.DebugPrint("Connection Received!");
            };
            await myCommModule.serverListener.BindServiceNameAsync(serviceName);
            return;
        }