Esempio n. 1
0
        public void Disconnect(User user)
        {
            Connection.CurrentGroup.RemoveUser(user);
            OnUserDisconnect(user);
            PresentationController.UserDisconneced(user);

            if (Connection.CurrentPresentation != null && Connection.CurrentPresentation.Author.CompareTo(user.Username) == 0)
            {
                ClPresentationEnd();
            }

            foreach (User u in users.Keys)
            {
                if (u.Username == user.Username)
                {
                    lock (syncObj)
                    {
                        this.users.Remove(u);
                        foreach (User key in users.Keys)
                        {
                            ISharePCallback callback = users[key];
                            try {
                                callback.RefreshUsers(Connection.CurrentGroup.userList);
                                callback.UserLeave(user);
                            } catch
                            {
                                usersToRemove.Add(key);
                            }
                        }
                        RemoveUsers();
                    }
                    return;
                }
            }
        }
Esempio n. 2
0
        /// IShareP

        public ConnectionResult Connect(User user, byte[] password)
        {
            if (!users.ContainsValue(CurrentCallback))
            {
                lock (syncObj)
                {
                    if (SearchUsersByName(user.Username))
                    {
                        Log.LogInfo("Username already exists: " + user.Username);
                        return(ConnectionResult.UsernameExists);
                    }

                    if (Connection.CurrentGroup.passwordProtected && !Helper.CompareByteArrays(password, Connection.CurrentGroup.password))
                    {
                        Log.LogInfo("Wrong password. User: "******"Refused connection from banned user. User: "******"Callback faulted during Connect: " + key.Username);
                        }
                    }
                    RemoveUsers();
                    users.Add(user, CurrentCallback);
                    ICommunicationObject commObj = CurrentCallback as ICommunicationObject;
                    if (commObj != null)
                    {
                        commObj.Closed  += new EventHandler(CallBackFaulted);
                        commObj.Faulted += new EventHandler(CallBackFaulted);
                    }
                }

                Log.LogInfo("User connected: " + user.Username);
                return(ConnectionResult.Success);
            }
            Log.LogInfo("Refused connection of: " + user.Username);
            return(ConnectionResult.Error);
        }
Esempio n. 3
0
 public void ViewerChangeFocus(bool focus, User user)
 {
     if (!focus)
     {
         PresentationController.MarkCheater(user);
     }
     else
     {
         PresentationController.MarkNotCheater(user);
     }
 }
Esempio n. 4
0
        public ConnectionResult Reconnect(User user)
        {
            if (!users.ContainsValue(CurrentCallback))
            {
                lock (syncObj)
                {
                    bool exists = false;
                    foreach (var item in usersToReconnect)
                    {
                        if (item.Id.CompareTo(user.Id) == 0 &&
                            item.IP == user.IP)
                        {
                            exists = true;
                        }
                    }
                    if (!exists)
                    {
                        return(ConnectionResult.Error);
                    }
                    Connection.CurrentGroup.AddUser(user);
                    PresentationController.UserConnected(user);

                    foreach (User key in users.Keys)
                    {
                        ISharePCallback callback = users[key];
                        try
                        {
                            callback.RefreshUsers(Connection.CurrentGroup.userList);
                        }
                        catch
                        {
                            usersToRemove.Add(key);
                            Log.LogInfo("Callback faulted during Reconnect: " + key.Username);
                        }
                    }
                    RemoveUsers();
                    users.Add(user, CurrentCallback);
                    ICommunicationObject commObj = CurrentCallback as ICommunicationObject;
                    if (commObj != null)
                    {
                        commObj.Closed  += new EventHandler(CallBackFaulted);
                        commObj.Faulted += new EventHandler(CallBackFaulted);
                    }
                }

                Log.LogInfo("User reconnected: " + user.Username);
                return(ConnectionResult.Success);
            }
            Log.LogInfo("Refused reconnection from: " + user.Username);
            return(ConnectionResult.Error);
        }
Esempio n. 5
0
        public void BanUser(string username)
        {
            lock (syncObj)
            {
                foreach (User key in users.Keys)
                {
                    if (key.Username.CompareTo(username) == 0)
                    {
                        Log.LogInfo("Banning user: " + username);
                        ISharePCallback callback = users[key];
                        try
                        {
                            callback.BanUser();
                        }
                        catch
                        {
                            usersToRemove.Add(key);
                        }

                        usersInBan.Add(key);
                        Connection.CurrentGroup.RemoveUser(key);
                        PresentationController.UserDisconneced(key);

                        foreach (User u in users.Keys)
                        {
                            ISharePCallback cb = users[u];
                            try
                            {
                                cb.RefreshUsers(Connection.CurrentGroup.userList);
                                cb.UserLeave(u);
                            }
                            catch
                            {
                                usersToRemove.Add(u);
                            }
                        }

                        if (Connection.CurrentPresentation != null && Connection.CurrentPresentation.Author.CompareTo(key.Username) == 0)
                        {
                            ClPresentationEnd();
                        }

                        break;
                    }
                }
                RemoveUsers();
            }
        }