private async void btnSend_Click(object sender, EventArgs e) { var msg = this.rbxMsg.Text; if (string.IsNullOrWhiteSpace(msg)) { return; } var content = new UserMessageContent { From = userId, Content = msg }; content.To = string.Join(",", this.listView1.Items).Split(","); //传递对象存在bug,后期查找对应方法 //await conn.InvokeAsync("SendMessage", content); await conn.InvokeAsync("SendMessage", userId, groupId, msg); this.rbxMsg.Clear(); }
public async Task SendToGroup(UserMessageContent msg, string groupName) { await Clients.Group(groupName).ReceiveSendToGroup(msg); }
public async Task SendToUser(UserMessageContent msg, string userId) { await Clients.User(userId).ReceiveSendToUser(msg); }
public async Task SendToUsers(UserMessageContent msg, params string[] users) { await Clients.Users(users.ToList().AsReadOnly()).ReceiveSendToUsers(msg); }
public async Task SendToGroups(UserMessageContent msg, params string[] groups) { await Clients.Groups(groups.ToList().AsReadOnly()).ReceiveSendToGroups(msg); }