Ejemplo n.º 1
0
        public override async Task OnConnectedAsync()
        {
            SessionInfo.CasterSocketID = Context.ConnectionId;
            SessionInfo.StartTime      = DateTimeOffset.Now;
            SessionInfoList.AddOrUpdate(Context.ConnectionId, SessionInfo, (id, si) => SessionInfo);

            await base.OnConnectedAsync();
        }
Ejemplo n.º 2
0
        public override async Task OnConnectedAsync()
        {
            SessionInfo = new RCSessionInfo()
            {
                RCDeviceSocketID = Context.ConnectionId,
                StartTime        = DateTimeOffset.Now
            };
            SessionInfoList.AddOrUpdate(Context.ConnectionId, SessionInfo, (id, si) => SessionInfo);

            await base.OnConnectedAsync();
        }
Ejemplo n.º 3
0
        public override async Task OnDisconnectedAsync(Exception exception)
        {
            SessionInfoList.Remove(Context.ConnectionId, out _);

            if (SessionInfo.Mode == Shared.Enums.RemoteControlMode.Normal)
            {
                await RCBrowserHubContext.Clients.Clients(ViewerList).SendAsync("ScreenCasterDisconnected");
            }
            else if (SessionInfo.Mode == Shared.Enums.RemoteControlMode.Unattended)
            {
                if (ViewerList.Count > 0)
                {
                    await RCBrowserHubContext.Clients.Clients(ViewerList).SendAsync("Reconnecting");

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

            await base.OnDisconnectedAsync(exception);
        }
Ejemplo n.º 4
0
        public Task GetSessionID()
        {
            var random    = new Random();
            var sessionId = "";

            while (string.IsNullOrWhiteSpace(sessionId) ||
                   SessionInfoList.ContainsKey(sessionId))
            {
                for (var i = 0; i < 3; i++)
                {
                    sessionId += random.Next(0, 999).ToString().PadLeft(3, '0');
                }
            }

            Context.Items["SessionID"] = sessionId;

            SessionInfoList[Context.ConnectionId].AttendedSessionID = sessionId;

            return(Clients.Caller.SendAsync("SessionID", sessionId));
        }