Exemple #1
0
        public void OnSessionTerminationRequested(Client client, UInt32 sessionId, char[] sessionKey, ref UInt32 sessionStatus)
        {
            if (isSessionAlive(sessionKey))
            {
                ScreencastingSession screencastSession = getSessionByKey(sessionKey);

                /* Only the sender can terminate a session */
                if (screencastSession.senderId == sessionId)
                {
                    sessionStatus = 0;
                    foreach (Client authenticatedClient in screencastSession.authenticatedClients.Keys)
                    {
                        UInt32 clientSessionId = screencastSession.authenticatedClients[authenticatedClient].sessionId;

                        try
                        {
                            authenticatedClient.OnSessionTermination(clientSessionId, sessionKey, sessionStatus);
                        }
                        catch (TransportException e)
                        {
                            Console.WriteLine("Caught Transport Exception: " + e.Message);
                            screencastSession.RemoveAuthenticatedUser(authenticatedClient);
                        }
                    }
                    screencastSession.authenticatedClients.Clear();
                    sessions.TryRemove(new string(sessionKey), out screencastSession);
                    return;
                }
            }

            sessionStatus = 1;
        }
Exemple #2
0
        public void OnSurfaceCommand(Client client, UInt32 sessionId, byte[] surfaceCommand)
        {
            ScreencastingSession session = GetSessionBySenderId(sessionId);

            if (session == null)
            {
                return;
            }

            if (isSessionAlive(session.sessionKey))
            {
                foreach (Client receiver in session.authenticatedClients.Keys)
                {
                    UInt32 receiverSessionId = session.authenticatedClients[receiver].sessionId;

                    if (receiverSessionId != sessionId)
                    {
                        try
                        {
                            receiver.OnSendSurfaceCommand(receiverSessionId, surfaceCommand);
                        }
                        catch (TransportException e)
                        {
                            Console.WriteLine("Caught Transport Exception: " + e.Message);
                            session.RemoveAuthenticatedUser(receiver);
                        }
                    }
                }
            }
        }
Exemple #3
0
        public void OnSessionCreateRequested(Client client, string username, string password, ref UInt32 sessionId, ref char[] sessionKey)
        {
            sessionId  = GenerateUniqueSessionId();
            sessionKey = GenerateUniqueSessionKey();

            ScreencastingSession screencastSession = new ScreencastingSession(sessionKey, sessionId, username, password, client);

            sessions.TryAdd(new string(sessionKey), screencastSession);
            screencastSession.AddFirstUser(client, sessionId, username);
        }
Exemple #4
0
        public void OnRecvMouseEvent(Client client, UInt32 sessionId, char[] sessionKey, ref UInt32 sessionStatus, UInt16 pointerFlags, int x, int y)
        {
            if (isSessionAlive(sessionKey))
            {
                ScreencastingSession screencastSession = getSessionByKey(sessionKey);
                screencastSession.SendMouseEventToSender(pointerFlags, x, y);
                return;
            }

            sessionStatus = 1;
        }
Exemple #5
0
        public void OnSessionRemoteAccessPermissionSet(Client client, char[] sessionKey, string username, Boolean permission)
        {
            ScreencastingSession screencastSession = getSessionByKey(sessionKey);

            if (permission)
            {
                screencastSession.GrantRemoteAccess(client, username);
            }
            else
            {
                screencastSession.DenyRemoteAccess(client, username);
            }
        }
Exemple #6
0
        public void OnRecvKeyboardEvent(Client client, UInt32 sessionId, char[] sessionKey, ref UInt32 sessionStatus, UInt16 pointerFlag, UInt16 keyCode)
        {
            Console.WriteLine("SessionManager.OnRecvKeyboardEvent sessionKey: {0} keyCode: {1}",
                              new string(sessionKey), keyCode);

            if (isSessionAlive(sessionKey))
            {
                ScreencastingSession screencastSession = getSessionByKey(sessionKey);
                screencastSession.SendKeyboardEventToSender(pointerFlag, keyCode);
                return;
            }

            sessionStatus = 1;
        }
Exemple #7
0
        public void OnSessionAuthenticationRequested(Client client, UInt32 sessionId, char[] sessionKey, string username, string password, ref UInt32 sessionStatus)
        {
            if (isSessionAlive(sessionKey))
            {
                ScreencastingSession screencastSession = getSessionByKey(sessionKey);

                if (screencastSession.Authenticate(client, sessionId, username, password))
                {
                    OnSessionParticipantListUpdated(screencastSession.sessionKey);
                    screencastSession.UpdateNotifications("joined", username);
                    sessionStatus = 0;
                    return;
                }
            }

            sessionStatus = 1;
        }
Exemple #8
0
        public void OnSessionLeaveRequested(Client client, UInt32 sessionId, char[] sessionKey, ref UInt32 sessionStatus, string username)
        {
            if (isSessionAlive(sessionKey))
            {
                ScreencastingSession screencastSession = getSessionByKey(sessionKey);

                if (screencastSession.authenticatedClients.ContainsKey(client))
                {
                    screencastSession.RemoveAuthenticatedUser(client, username, sessionId);
                    OnSessionParticipantListUpdated(screencastSession.sessionKey);
                    sessionStatus = 0;

                    return;
                }
            }

            sessionStatus = 1;
        }
Exemple #9
0
        private void OnSessionParticipantListUpdated(char[] sessionKey)
        {
            if (isSessionAlive(sessionKey))
            {
                ScreencastingSession session = getSessionByKey(sessionKey);
                ArrayList            participantUsernames = session.GetParticipantUsernames();

                foreach (Client client in session.authenticatedClients.Keys)
                {
                    try
                    {
                        client.OnSessionParticipantListUpdated(participantUsernames);
                    }
                    catch (TransportException e)
                    {
                        Console.WriteLine("Caught Transport Exception: " + e.Message);
                        session.RemoveAuthenticatedUser(client);
                    }
                }
            }
        }
Exemple #10
0
        public void OnSessionJoinRequested(Client client, char[] sessionKey, ref UInt32 sessionId, ref UInt32 sessionStatus, ref byte sessionFlags)
        {
            if (isSessionAlive(sessionKey))
            {
                ScreencastingSession screencastSession = getSessionByKey(sessionKey);
                sessionId = GenerateUniqueSessionId();
                screencastSession.AddJoinedUser(client, sessionId);
                sessionStatus = 0;

                if (screencastSession.isPasswordProtected())
                {
                    sessionFlags = SESSION_FLAGS_PASSWORD_PROTECTED;
                }
                else
                {
                    sessionFlags = SESSION_FLAGS_NON_PASSWORD_PROTECTED;
                }

                return;
            }

            sessionStatus = 1;
        }
        public void OnSessionCreateRequested(Client client, string username, string password, ref UInt32 sessionId, ref char[] sessionKey)
        {
            sessionId = GenerateUniqueSessionId();
            sessionKey = GenerateUniqueSessionKey();

            ScreencastingSession screencastSession = new ScreencastingSession(sessionKey, sessionId, username, password, client);

            sessions.TryAdd(new string(sessionKey), screencastSession);
            screencastSession.AddFirstUser(client, sessionId, username);
        }
        public void OnSessionCreateRequested(Client client, string username, string password, ref UInt32 sessionId, ref char[] sessionKey)
        {
            Console.WriteLine("ScreenSessions.OnSessionCreateRequested");
            Console.WriteLine("username:{0} password:{1}", username, password);

            sessionId = GenerateUniqueId();
            sessionKey = GenerateUniqueKey();
            string sessionKeyString = new string(sessionKey);

            ScreencastingSession screencastSession = new ScreencastingSession(sessionKey, sessionId, username, password);

            sessions.Add(sessionKeyString, screencastSession);
            screencastSession.AddAuthenticatedUser(client, sessionId, username);
        }
Exemple #13
0
        public void OnSessionTermRemoteAccessRequested(Client client, char[] sessionKey, string username)
        {
            ScreencastingSession screencastSession = getSessionByKey(sessionKey);

            screencastSession.TermRemoteAccessRequested(username);
        }
Exemple #14
0
        public void OnSessionRemoteAccessRequested(Client receiverClient, char[] sessionKey, string username)
        {
            ScreencastingSession screencastSession = getSessionByKey(sessionKey);

            screencastSession.AddRemoteAccessRequest(receiverClient, username);
        }