Esempio n. 1
0
        public override async Task OnDisconnectedAsync(Exception exception)
        {
            if (Context.Items.ContainsKey("SessionID") && AttendedSessionList.ContainsKey(Context.Items["SessionID"].ToString()))
            {
                while (!AttendedSessionList.TryRemove(Context.Items["SessionID"].ToString(), out var value))
                {
                    await Task.Delay(1000);
                }
                await RCBrowserHub.Clients.Clients(ViewerList).SendAsync("ScreenCasterDisconnected");
            }
            else
            {
                if (ViewerList.Count > 0)
                {
                    await RCBrowserHub.Clients.Clients(ViewerList).SendAsync("Reconnecting");

                    await DeviceHub.Clients.Client(ServiceID).SendAsync("RestartScreenCaster", ViewerList, ServiceID, Context.ConnectionId);
                }
            }

            if (!string.IsNullOrWhiteSpace(MachineName) && MachineNameToSessionIDLookup.ContainsKey(MachineName))
            {
                while (!MachineNameToSessionIDLookup.TryRemove(MachineName, out _))
                {
                    await Task.Delay(1000);
                }
            }
            await base.OnDisconnectedAsync(exception);
        }
Esempio n. 2
0
        public override async Task OnDisconnectedAsync(Exception exception)
        {
            await base.OnDisconnectedAsync(exception);

            if (AttendedSessionList.ContainsKey(Context.Items["SessionID"].ToString()))
            {
                while (!AttendedSessionList.TryRemove(Context.Items["SessionID"].ToString(), out var value))
                {
                    await Task.Delay(1000);
                }
            }
        }
Esempio n. 3
0
        public async Task GetSessionID()
        {
            var random    = new Random();
            var sessionID = "";

            for (var i = 0; i < 3; i++)
            {
                sessionID += random.Next(0, 999).ToString().PadLeft(3, '0');
            }
            Context.Items["SessionID"] = sessionID;

            while (!AttendedSessionList.TryAdd(sessionID, Context.ConnectionId))
            {
                await Task.Delay(1000);
            }

            await Clients.Caller.SendAsync("SessionID", sessionID);
        }