Example #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        UIFormControl.OnCheckPermissions += new EventHandler(UIFormControl_OnCheckPermissions);
        UIFormControl.OnBeforeValidate   += new EventHandler(UIFormOnOnBeforeValidate);

        ScriptHelper.RegisterDialogScript(Page);

        ChatUserInfo user = TypedEditedObject;

        // Setting attributes of controls
        if (user != null)
        {
            if (user.IsAnonymous)
            {
                RedirectToInformation(ResHelper.GetString("chat.user.cannoteditanonymoususer"));
                return;
            }

            UserInfo cmsUser = UserInfoProvider.GetUserInfo(user.ChatUserUserID.Value);

            pnlStaticUser.Visible = true;
            fUserSelector.Visible = false;
            fUserSelector.Value   = user.ChatUserUserID;

            txtUserNameStaticValue.Text = HTMLHelper.HTMLEncode(cmsUser.FullName);
            btnEditUser.OnClientClick   = "modalDialog('" + CMSContext.ResolveDialogUrl("~/CMSModules/Membership/Pages/Users/User_Edit_Dialog.aspx") + "?userid=" + user.ChatUserUserID + "', 'UserEdit', 950, 800); return false;";
            btnEditUser.Text            = GetString("general.edit");
        }
        else
        {
            // New object
            pnlStaticUser.Visible = false;
            fUserSelector.Visible = true;
        }
    }
Example #2
0
 public static string BuildWhoReply(string channelName, ChatUserInfo userInfo, string modes)
 {
     return(ChatCommandBase.BuildReply(
                WhoReply,
                $"* {channelName} " +
                $"{userInfo.UserName} {userInfo.PublicIPAddress} * {userInfo.NickName} {modes} param7"));
 }
Example #3
0
 public static string BuildWhoIsUserReply(ChatUserInfo userInfo)
 {
     return(ChatCommandBase.BuildReply(
                WhoIsUser,
                $"{userInfo.NickName} {userInfo.Name} {userInfo.UserName} {userInfo.PublicIPAddress} *",
                userInfo.UserName));
 }
Example #4
0
 public static string BuildWhoReply(string channelName, ChatUserInfo userInfo, string modes)
 {
     return(ChatResponseBase.BuildResponse(
                ChatReplyCode.WhoReply,
                $"param1 {channelName} " +
                $"{userInfo.UserName} {userInfo.PublicIPAddress} param5 {userInfo.NickName} {modes} param8"));
 }
Example #5
0
    /// <summary>
    /// Validates form.
    /// </summary>
    private void OnBeforeValidate(object sender, EventArgs e)
    {
        int      selectedCMSUserId = ValidationHelper.GetInteger(Control.GetFieldValue("ChatUserUserID"), 0);
        UserInfo user     = UserInfoProvider.GetUserInfo(selectedCMSUserId);
        string   nickname = Control.GetFieldValue("ChatUserNickname") as string;

        // Validate form - user and nickname fields must be filled
        if ((user == null) || (String.IsNullOrWhiteSpace(nickname)))
        {
            ShowErrorAndStopProcessing("chat.user.erroridnickname");

            return;
        }

        if (user.IsPublic())
        {
            ShowErrorAndStopProcessing("chat.cantassociatechatusertopublic");

            return;
        }

        // Creating a new object
        if (Control.IsInsertMode)
        {
            // Check if userID is unique in ChatUser table if adding a new user
            if (ChatUserInfoProvider.GetChatUserByUserID(selectedCMSUserId) != null)
            {
                ShowErrorAndStopProcessing("chat.user.erroridunique");

                return;
            }
        }

        // Check nickname only if text has been changed
        ChatUserInfo editedChatUser = Control.EditedObject as ChatUserInfo;

        if (Control.IsInsertMode || (nickname != editedChatUser.ChatUserNickname))
        {
            try
            {
                ChatUserHelper.VerifyNicknameIsValid(ref nickname);
            }
            catch (ChatServiceException ex)
            {
                ShowErrorAndStopProcessing(ex.StatusMessage);

                return;
            }


            // Check if Nickname is unique in registered users
            if (!ChatUserHelper.IsNicknameAvailable(nickname))
            {
                ShowErrorAndStopProcessing("chat.user.errornickunique");

                return;
            }
        }
    }
Example #6
0
 public static string BuildEndOfWhoIsReply(ChatUserInfo userInfo)
 {
     return(ChatCommandBase.BuildReply(
                EndOfWhoIs,
                $"{userInfo.NickName} {userInfo.Name}",
                "End of /WHOIS list."
                ));
 }
 private static string BuildEndOfWhoIsReply(ChatUserInfo userInfo)
 {
     return(ChatResponseBase.BuildResponse(
                ChatReplyCode.EndOfWhoIs,
                $"{userInfo.NickName} {userInfo.Name}",
                "End of /WHOIS list."
                ));
 }
 private static string BuildWhoIsChannelReply(ChatUserInfo userInfo, string channelName)
 {
     return(ChatResponseBase.BuildResponse(
                ChatReplyCode.WhoIsChannels,
                $"{userInfo.NickName} {userInfo.Name}",
                channelName
                ));
 }
Example #9
0
 public static string BuildWhoIsChannelReply(ChatUserInfo userInfo, string channelName)
 {
     return(ChatCommandBase.BuildReply(
                WhoIsChannels,
                $"{userInfo.NickName} {userInfo.Name}",
                channelName
                ));
 }
Example #10
0
        public async Task <long> AwaitUser(ChatUserInfo user)
        {
            Log.Info("Awaiting for " + user.Name);
            var ticket = _ticketCounter++;

            _awaitingUsers.Add(ticket, user);
            Fiber.Shedule(() => ExpireTicketAsync(ticket), TimeSpan.FromSeconds(10), LockType.Write);
            return(ticket);
        }
 public ChatDataList()
 {
     this.chatUserInfoData = new ChatUserInfo();
     this.HallChatData     = new Queue <ChatMessageNew>();
     this.FriendChatData   = new Dictionary <string, List <ChatMessageNew> >();
     this.LobbyChatData    = new Queue <ChatMessageNew>();
     this.tempHallData     = new Queue <ChatMessageNew>();
     this.vipHallData      = new List <ChatMessageNew>();
 }
Example #12
0
 public static string BuildWhoIsUserReply(ChatUserInfo userInfo)
 {
     return(ChatResponseBase.BuildResponse(
                ChatReplyCode.WhoIsUser,
                $"{userInfo.NickName} {userInfo.Name} {userInfo.UserName} {userInfo.PublicIPAddress} *",
                userInfo.UserName)
            +
            BuildJoinedChannelReply(userInfo)
            +
            BuildEndOfWhoIsReply(userInfo));
 }
        public async Task SetChatSpecificUserInfoAsync(int chatId, int userId, ChatUserInfo info)
        {
            var response = await _client.PutAsJsonAsync($"chats/{chatId}/users/{userId}/info", info);

            if (!response.IsSuccessStatusCode)
            {
                return;
            }

            lock (_lock)
                _poller?.SetChatUserInfo(userId, chatId, info);
        }
Example #14
0
        public override System.Threading.Tasks.Task OnDisconnected(bool stopCalled)
        {
            UpdateSfIdFromQuerystring();
            string       userName = UserName();
            ChatUserInfo user     = _userList.SingleOrDefault(u => u.StoreFrontConfigurationId == _currentStoreFrontConfigurationId && u.Name.ToLower() == userName.ToLower());

            if (user.IsSet)
            {
                _userList.Remove(user);
                CurrentStoreFrontGroup.UserLeft(userName);
                CurrentStoreFrontGroup.UpdatedUserList(CurrentStoreFrontUserList());
            }
            return(base.OnDisconnected(stopCalled));
        }
Example #15
0
    /// <summary>
    /// Handles loaded data.
    /// </summary>
    private void OnAfterDataLoad(object sender, EventArgs e)
    {
        ChatUserInfo user = Control.EditedObject as ChatUserInfo;

        // Anonymous users cannot be edited
        if (!Control.IsInsertMode && (user.ChatUserID > 0) && (user.IsAnonymous || !user.ChatUserUserID.HasValue))
        {
            ShowErrorAndStopProcessing("chat.user.cannoteditanonymoususer");
            Control.Enabled = false;
            Control.SubmitButton.Enabled = false;

            return;
        }
    }
Example #16
0
        protected override void CheckRequest()
        {
            base.CheckRequest();

            var result = from s in ChatSessionManager.Sessions.Values
                         where s.UserInfo.NickName == _request.NickName
                         select s.UserInfo;

            if (result.Count() != 1)
            {
                _errorCode = ChatError.NoSuchNick;
                return;
            }
            _userInfo = result.FirstOrDefault();
        }
Example #17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (EditedObjectParent != null)
        {
            editElem.ChatRoomID = ((ChatRoomInfo)EditedObjectParent).ChatRoomID;
        }

        // If editing, add user's nickname to macro resolver, so it can be retrieved when applying breacrumb attribute
        if (EditedObject != null)
        {
            int chatUserID = ((ChatRoomUserInfo)EditedObject).ChatRoomUserChatUserID;

            ChatUserInfo chatUser = ChatUserInfoProvider.GetChatUserInfo(chatUserID);

            CMSContext.CurrentResolver.SetNamedSourceData("EditedChatUserNickname", chatUser.ChatUserNickname);
        }
    }
 private void OnMsg_Chat_Login(MobaMessage msg)
 {
     if (msg != null)
     {
         OperationResponse operationResponse = msg.Param as OperationResponse;
         if (operationResponse != null)
         {
             byte[]       buffer       = (byte[])operationResponse.Parameters[100];
             ChatUserInfo chatUserInfo = SerializeHelper.Deserialize <ChatUserInfo>(buffer);
             if (chatUserInfo != null)
             {
                 this.data.chatUserInfoData = chatUserInfo;
             }
         }
         base.Data = this.data;
     }
 }
Example #19
0
    protected void HandleUsersChanged(ChatUserInfo[] joins, ChatUserInfo[] leaves, ChatUserInfo[] infoChanges)
    {
        for (int i = 0; i < leaves.Length; ++i)
        {
            DebugOverlay.Instance.AddViewportText(leaves[i].DisplayName + " left");
        }

        for (int i = 0; i < infoChanges.Length; ++i)
        {
            // TODO: if we were displaying user attributes we would update them here
        }

        for (int i = 0; i < joins.Length; ++i)
        {
            DebugOverlay.Instance.AddViewportText(leaves[i].DisplayName + " joined");
        }
    }
Example #20
0
        private static string BuildJoinedChannelReply(ChatUserInfo userInfo)
        {
            string buffer = "";

            if (userInfo.JoinedChannels.Count() != 0)
            {
                string channelNames = "";
                //todo remove last space
                foreach (var channel in userInfo.JoinedChannels)
                {
                    channelNames += $"@{channel.Property.ChannelName} ";
                }

                buffer +=
                    BuildWhoIsChannelReply(userInfo, channelNames);
            }
            return(buffer);
        }
 public void SetChatUserInfo(int userId, int chatId, ChatUserInfo chatUserInfo)
 {
     lock (ChatUserInfosCache)
     {
         var key = new ChatUserId(userId, chatId);
         if (ChatUserInfosCache.ContainsKey(key))
         {
             ChatUserInfosCache[key] = chatUserInfo;
         }
         else
         {
             ChatUserInfosCache.Add(key, chatUserInfo);
         }
         if (_newChatUserInfosHandlers.ContainsKey(key))
         {
             _newChatUserInfosHandlers[key]?.Invoke(this, chatUserInfo);
         }
     }
 }
Example #22
0
    void OnMessageReceived(Packet <IScenePeerClient> packet)
    {
        var          dto = new ChatMessageDTO();
        ChatUserInfo temp;

        if (_UsersInfos.TryGetValue(packet.Connection.Id, out temp) == false)
        {
            temp          = new ChatUserInfo();
            temp.ClientId = packet.Connection.Id;
            temp.User     = "";
        }
        dto.UserInfo  = temp;
        dto.Message   = packet.ReadObject <string>();
        dto.TimeStamp = _env.Clock;

        AddMessageToCache(dto);

        _scene.Broadcast("chat", dto, PacketPriority.MEDIUM_PRIORITY, PacketReliability.RELIABLE);
    }
Example #23
0
        public override void CheckRequest()
        {
            base.CheckRequest();
            if (_errorCode != Entity.Structure.ChatError.NoError)
            {
                return;
            }

            var result = from s in ChatSessionManager.Sessions.Values
                         where s.UserInfo.NickName == _cmd.NickName
                         select s.UserInfo;

            if (result.Count() != 1)
            {
                _errorCode     = Entity.Structure.ChatError.IRCError;
                _sendingBuffer = ChatIRCError.BuildNoSuchNickError();
                return;
            }
            _userInfo = result.FirstOrDefault();
        }
Example #24
0
        public async Task <ChatUserInfo> TryRegisterUser(string name)
        {
            if (_usersByName.ContainsKey(name))
            {
                return(null);
            }

            uint id = _userCounter++;

            var user = new ChatUserInfo
            {
                Id   = id,
                Name = name
            };

            _usersByName.Add(name, user);
            _usersById.Add(id, user);

            return(user);
        }
Example #25
0
        protected void Join()
        {
            string userName = UserName();

            Groups.Add(Context.ConnectionId, userName);
            Groups.Add(Context.ConnectionId, StoreFrontGroupName(_currentStoreFrontConfigurationId));
            ChatUserInfo user = _userList.SingleOrDefault(u => u.StoreFrontConfigurationId == _currentStoreFrontConfigurationId && u.Name.ToLower() == userName.ToLower());

            if (!user.IsSet)
            {
                user = new ChatUserInfo()
                {
                    ConnectionId = this.Context.ConnectionId, Name = userName, StoreFrontConfigurationId = _currentStoreFrontConfigurationId, IsSet = true
                };
                _userList.Add(user);
                CurrentStoreFrontGroup.UpdatedUserList(CurrentStoreFrontUserList());
            }

            CurrentStoreFrontGroup.UserJoined(userName);
            Clients.Caller.UpdatedUserList(CurrentStoreFrontUserList());
        }
Example #26
0
        private void UserExitHandler(UserExit userExit)
        {
            if (isSelfExitRoom)
            {
                isSelfExitRoom = false;
                MessageBox.Show("你已经离开了房间");
                ChatUserInfos.Clear();
                ChatRecords.Clear();
                NetworkClient.Stop();
                GlobalValue.IsInRoom = false;
                MainWindow.VM.Status = "Not in room....";
                return;
            }

            ChatUserInfo chatUserInfo = ChatUserInfos.FirstOrDefault(c => c.UserName.Equals(userExit.UserName));

            if (chatUserInfo != null)
            {
                ChatUserInfos.Remove(chatUserInfo);
            }
        }
Example #27
0
        public async Task <LoginResult> Login(string name)
        {
            Log.Info(name + " is logging in");

            ActorProxy <IUserManager> chatManager = await Node.GetActor <IUserManager>();

            ChatUserInfo userInfo = await chatManager.Channel.TryRegisterUser(name);

            if (userInfo == null)
            {
                Log.Warn("name in use");
                return(LoginResult.NameInUse);
            }

            _user = userInfo;

            SetHandler <IChatService>(this);
            RemoveHandler <IChatLogin>();

            Log = LogManager.GetLogger(string.Format("ChatClient<NetId:{0}, UserId:{1}, Name:{2}>", Channel.Id, userInfo.Id, userInfo.Name));
            Log.Info("login successfull");

            return(LoginResult.Ok);
        }
    void OnMessageReceived(Packet<IScenePeerClient> packet)
    {
        var dto = new ChatMessageDTO();
        ChatUserInfo temp;

        if (_UsersInfos.TryGetValue(packet.Connection.Id, out temp) == false)
        {
            temp = new ChatUserInfo();
            temp.ClientId = packet.Connection.Id;
            temp.User = "";
        }
        dto.UserInfo = temp;
        dto.Message = packet.ReadObject<string>();
        dto.TimeStamp = _env.Clock;

        AddMessageToCache(dto);

        _scene.Broadcast("chat", dto, PacketPriority.MEDIUM_PRIORITY, PacketReliability.RELIABLE);
    }
Example #29
0
            void IChatChannelListener.ChatChannelUserChangeCallback(string channelName, ChatUserInfo[] joinList, ChatUserInfo[] leaveList, ChatUserInfo[] userInfoList)
            {
                for (int i = 0; i < leaveList.Length; ++i)
                {
                    int index = m_ChannelUsers.IndexOf(leaveList[i]);
                    if (index >= 0)
                    {
                        m_ChannelUsers.RemoveAt(index);
                    }
                }

                for (int i = 0; i < userInfoList.Length; ++i)
                {
                    // this will find the existing user with the same name
                    int index = m_ChannelUsers.IndexOf(userInfoList[i]);
                    if (index >= 0)
                    {
                        m_ChannelUsers.RemoveAt(index);
                    }

                    m_ChannelUsers.Add(userInfoList[i]);
                }

                for (int i = 0; i < joinList.Length; ++i)
                {
                    m_ChannelUsers.Add(joinList[i]);
                }

                FireUsersChanged(m_ChannelName, joinList, leaveList, userInfoList);
            }
Example #30
0
 public static string BuildEndOfWhoReply(ChatUserInfo userInfo)
 {
     return(ChatCommandBase.BuildReply(EndOfWho, $"* {userInfo.NickName} param3"));
 }
Example #31
0
 protected void FireUsersChanged(string channelName, ChatUserInfo[] joinList, ChatUserInfo[] leaveList, ChatUserInfo[] userInfoList)
 {
     try
     {
         if (m_ChatController.UsersChanged != null)
         {
             m_ChatController.UsersChanged(channelName, joinList, leaveList, userInfoList);
         }
     }
     catch (Exception x)
     {
         ReportError(x.ToString());
     }
 }
Example #32
0
 public static string BuildPingReply(ChatUserInfo userInfo)
 {
     return(userInfo.BuildReply(PONG));
 }
Example #33
0
 public static string BuildWelcomeReply(ChatUserInfo userInfo)
 {
     return(userInfo.BuildReply(
                Welcome, userInfo.NickName, "Welcome to RetrosSpy!"));
 }
Example #34
0
 public static string BuildEndOfGetKeyReply(ChatUserInfo info, string cookie)
 {
     return(info.BuildReply(EndGetKey, $"param1 param2 {cookie} param4", "End of GETKEY."));
 }