예제 #1
0
        public void ForceChannelSwitch(SockChatUser user, SockChatChannel chan)
        {
            if (!Channels.Contains(chan))
            {
                return;
            }

            int             messageId = SockChatMessage.NextMessageId;
            SockChatChannel oldChan   = user.Channel;

            oldChan.Send(new UserChannelLeavePacket(user), messageId);
            chan.Send(new UserChannelJoinPacket(user), messageId);

            user.Send(new ContextClearPacket(ContextClearMode.MessagesUsers));
            user.Send(new ContextUsersPacket(chan.GetUsers(new[] { user })));

            IChatMessage[] msgs = GetChannelBacklog(chan);

            foreach (IChatMessage msg in msgs)
            {
                user.Send(new ContextMessagePacket(msg));
            }

            user.ForceChannel(chan);
            oldChan.UserLeave(user);
            chan.UserJoin(user);

            if (oldChan.IsTemporary && oldChan.Owner == user)
            {
                DeleteChannel(oldChan);
            }
        }
예제 #2
0
        public void UserLeave(SockChatChannel chan, SockChatUser user, string type = Constants.LEAVE_NORMAL)
        {
            if (chan == null)
            {
                Channels.Where(x => x.Users.Contains(user)).ToList().ForEach(x => UserLeave(x, user, type));
                return;
            }

            if (chan.IsTemporary && chan.Owner == user)
            {
                DeleteChannel(chan);
            }

            chan.UserLeave(user);
            HandleLeave(chan, user, type);
        }