示例#1
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);
                        }
                    }
                }
            }
        }
示例#2
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;
        }
示例#3
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;
        }
示例#4
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);
                    }
                }
            }
        }