Esempio n. 1
0
        void OnUserLeave(User user)
        {
            //Debug.Log(string.Format("User Left: {0}   userId: {1}   partIx: {2}", user.username, user.id, user.hash));
            UserGroup gp = HashUserToGroup(user);

            if (gp == null)
            {
                return;
            }

            if (gp.Contains(user) != UserGroup.UserStatus.NotInGroup)
            {
                lock (usersLeaving)
                {
                    usersLeaving.Add(user);
                }
                gp.RemoveUser(user);
            }
        }
Esempio n. 2
0
        public override void OnPeriscopeChatEvent(User user, string color, string message)
        {
            //Debug.Log(string.Format("Received ChatEvent: {0}   userId: {1}   hash: {2}   comment: {3}", user.username, user.id, user.hash, message));
            UserGroup gp = HashUserToGroup(user);

            if (gp == null)
            {
                return;
            }
            if (gp.Contains(user) == UserGroup.UserStatus.Exists)
            {
                // already in the group - text back once in a while
                if (UnityEngine.Random.Range(0, chatResponseProbability) == 0)
                {
                    SendMessageToGroupMember(user, RandMessage(gp.chatResponseMessages));
                }
            }

            activeUsers.Add(user.Hash, user);
        }
Esempio n. 3
0
        /*
         * EventsProcessor Callbacks
         */
        public override void OnPeriscopeJoinEvent(User user, string color)
        {
            //Debug.Log(string.Format("Received JoinEvent: {0}   userId: {1}   hash: {2}", user.username, user.id, user.hash));
            UserGroup gp = HashUserToGroup(user);

            if (gp == null)
            {
                return;
            }
            if (gp.Contains(user, true, !GroupLimitsExist) != UserGroup.UserStatus.NotInGroup)              // try add user to a group upon join
            {
                SendMessageToGroupMember(user, RandMessage(gp.joinMessages));
            }
            else
            {
                SendMessageToGroupMember(user, RandMessage(gp.groupFullMessages));
            }

            activeUsers.Add(user.Hash, user);
        }
Esempio n. 4
0
        public override void OnPeriscopeHeartEvent(User user, string color)
        {
            //Debug.Log(string.Format("Received HeartEvent: userId: {0}   hash: {1}", user.id, user.hash));
            // aggregate in the user's UserGroup
            UserGroup gp = HashUserToGroup(user);

            if (gp == null)
            {
                return;
            }

            var status = gp.Contains(user, true, !GroupLimitsExist);             // try add user to a group upon hearting

            if (status != UserGroup.UserStatus.NotInGroup)
            {
                gp.heartCount += 1;
                if (status == UserGroup.UserStatus.Added)
                {
                    SendMessageToGroupMember(user, RandMessage(gp.joinMessages));
                }
                else
                {
                    // already in the group - show appreciation once in a while
                    if (UnityEngine.Random.Range(0, heartResponseProbability) == 0)
                    {
                        SendMessageToGroupMember(user, RandMessage(gp.heartResponseMessages));
                    }
                }
            }
            else if (GroupLimitsExist && !activeUsers.ContainsKey(user.Hash))
            {
                SendMessageToGroupMember(user, RandMessage(gp.groupFullMessages));
            }

            activeUsers.Add(user.Hash, user);
        }