Exemplo n.º 1
0
        private void GatRoomData()
        {
            DataTable dt  = new GroupChatDataBLL().GetRoomDataBLL("room1");
            int       len = dt.Rows.Count;

            string[] strMsg = new string[len];
            for (int j = len - 1; j > 0; j--)
            {
                Clients.Client(this.Context.ConnectionId).receiveDataMsg($"{strMsg[j]}");//输出群聊
            }
        }
Exemplo n.º 2
0
        public void SendRoomNameMsg(string roomName, string msg)
        {
            string SenderId = this.Context.ConnectionId;
            string sendName = new UserBLL().QueryUserNameBLL(SenderId);
            GroupChatDataModels groupChatDataModels;

            groupChatDataModels = new GroupChatDataModels()
            {
                roomName = roomName,
                sendName = sendName,
                msg      = msg
            };
            int a = new GroupChatDataBLL().AddChatDataBLL(groupChatDataModels);

            //向指定组发送消息,如果这个组包含自己,将自己除外
            Clients.Group(roomName, this.Context.ConnectionId).receiveMsg($"用户【{this.Context.ConnectionId}】发来消息:{msg}");
        }