Exemplo n.º 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;
        }
    }
Exemplo n.º 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"));
 }
Exemplo n.º 3
0
 public static string BuildWhoIsUserReply(ChatUserInfo userInfo)
 {
     return(ChatCommandBase.BuildReply(
                WhoIsUser,
                $"{userInfo.NickName} {userInfo.Name} {userInfo.UserName} {userInfo.PublicIPAddress} *",
                userInfo.UserName));
 }
Exemplo n.º 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"));
 }
Exemplo n.º 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;
            }
        }
    }
Exemplo n.º 6
0
 public static string BuildEndOfWhoIsReply(ChatUserInfo userInfo)
 {
     return(ChatCommandBase.BuildReply(
                EndOfWhoIs,
                $"{userInfo.NickName} {userInfo.Name}",
                "End of /WHOIS list."
                ));
 }
Exemplo n.º 7
0
 private static string BuildEndOfWhoIsReply(ChatUserInfo userInfo)
 {
     return(ChatResponseBase.BuildResponse(
                ChatReplyCode.EndOfWhoIs,
                $"{userInfo.NickName} {userInfo.Name}",
                "End of /WHOIS list."
                ));
 }
Exemplo n.º 8
0
 private static string BuildWhoIsChannelReply(ChatUserInfo userInfo, string channelName)
 {
     return(ChatResponseBase.BuildResponse(
                ChatReplyCode.WhoIsChannels,
                $"{userInfo.NickName} {userInfo.Name}",
                channelName
                ));
 }
Exemplo n.º 9
0
 public static string BuildWhoIsChannelReply(ChatUserInfo userInfo, string channelName)
 {
     return(ChatCommandBase.BuildReply(
                WhoIsChannels,
                $"{userInfo.NickName} {userInfo.Name}",
                channelName
                ));
 }
Exemplo n.º 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);
        }
Exemplo n.º 11
0
 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>();
 }
Exemplo n.º 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));
 }
Exemplo n.º 13
0
        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);
        }
Exemplo n.º 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));
        }
Exemplo n.º 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;
        }
    }
Exemplo n.º 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();
        }
Exemplo n.º 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);
        }
    }
Exemplo n.º 18
0
 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;
     }
 }
Exemplo n.º 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");
        }
    }
Exemplo n.º 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);
         }
     }
 }
Exemplo n.º 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);
    }
Exemplo n.º 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();
        }
Exemplo n.º 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);
        }
Exemplo n.º 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());
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
    }
Exemplo n.º 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);
            }
Exemplo n.º 30
0
 public static string BuildEndOfWhoReply(ChatUserInfo userInfo)
 {
     return(ChatCommandBase.BuildReply(EndOfWho, $"* {userInfo.NickName} param3"));
 }
Exemplo n.º 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());
     }
 }
Exemplo n.º 32
0
 public static string BuildPingReply(ChatUserInfo userInfo)
 {
     return(userInfo.BuildReply(PONG));
 }
Exemplo n.º 33
0
 public static string BuildWelcomeReply(ChatUserInfo userInfo)
 {
     return(userInfo.BuildReply(
                Welcome, userInfo.NickName, "Welcome to RetrosSpy!"));
 }
Exemplo n.º 34
0
 public static string BuildEndOfGetKeyReply(ChatUserInfo info, string cookie)
 {
     return(info.BuildReply(EndGetKey, $"param1 param2 {cookie} param4", "End of GETKEY."));
 }