Group invites

7 replies [Last post]
Posts: 1030

How exactly are they handled? I noticed there is no "decline" command. There's probably a time out? If so, where? And maybe add a decline command so other people can invite the person to a group (or are group invites overwritten, which isn't a good idea either).

Basically, you would want the following behavior:

Person 1 invites Person 2
Person 2 can either accept, decline or wait for the invite to expire (let's say 60s)

Person 3 wants to invite Person 2 into his group as well, this should only be possible when Person 2 either has declined the request of Person 1 or the invite by Person 1 has expired.

Posts: 1691

From what I remember, invites do time out after a while (defined in the feature's settings). No declining.

Not sure why overwriting an invite "isn't a good idea". Sure, there are plenty of ways it could be better, but this works plenty fine. Only time it'd be an issue is if someone else invites you to a group right before you accept and you join the wrong group, but its not like you can't just leave and join the other group.

Feel free to change it to that way if you want.

Posts: 1030

So invites are overwritten by default?
Where's the timeout defined?

EDIT:

Found the place it is defined.

Posts: 1691

Yep, overwritten by default.

Posts: 1030

Okay, one last thing I noticed there is no "group" channel.

I created one for admin channel but I was wondering if you could proofread it so I know it works as expected:

In Demogame.Server.World.cs

        public void SendToMods(BitStream data, ServerMessageType messageType)
        {
            if (_users.Count <= 0)
                return;
            foreach (var map in Maps)
            {
                map.SendToMods(data, messageType);
            }
            foreach (var map in InstancedMaps)
            {
                map.SendToMods(data, messageType);
            }
        }

And in Demogame.Server.Map.cs

        public void SendToMods(BitStream data, ServerMessageType messageType)
        {
            if (_users.Count == 0)
                return;
 
            foreach (var user in Users)
            {
                if(user.Permissions == UserPermissions.Moderator ||
                    user.Permissions == UserPermissions.LesserAdmin ||
                    user.Permissions == UserPermissions.Admin)
 
                    user.Send(data, messageType);
            }
        }

Is this the correct way?

Posts: 1691

Almost. It'd work, but not if you use more advanced permissions since permissions are bit flags so you should be checking the bits. Since Admin and LesserAdmin imply moderator, just do:

if (user.Permissions.IsSet(UserPermissions.Moderator))

Rest looks good.

Posts: 1030

What is level? Doesn't exist in the code.

Posts: 1691

Sorry, replace level with "user.Permissions".