private async Task SendToGroup <T>(T message, Constants.Enums.MessageReponseKey action, string groupName, bool isMySelf = false) { if (!string.IsNullOrEmpty(groupName)) { HubResponse <T> result = new HubResponse <T>() { IsSucceed = true, Data = message, ResponseKey = GetResponseKey(action) }; if (isMySelf) { await Clients.Group(groupName).SendAsync(Constants.HubMethods.ReceiveMethod, JObject.FromObject(result).ToString(Newtonsoft.Json.Formatting.None)); } else { await Clients.OthersInGroup(groupName).SendAsync(Constants.HubMethods.ReceiveMethod, JObject.FromObject(result).ToString(Newtonsoft.Json.Formatting.None)); } } else { await SendToCaller(Constants.HubMessages.UnknowErrorMsg, Constants.Enums.MessageReponseKey.Error); } }
private Task SendToConnection <T>(T message, Constants.Enums.MessageReponseKey action, string connectionId, bool isMySelf) { if (!string.IsNullOrEmpty(connectionId)) { HubResponse <T> result = new HubResponse <T>() { IsSucceed = true, Data = message, ResponseKey = GetResponseKey(action) }; if (isMySelf) { return(Clients.Client(connectionId).SendAsync(Constants.HubMethods.ReceiveMethod, JObject.FromObject(result))); } else { return(Clients.OthersInGroup(connectionId).SendAsync(Constants.HubMethods.ReceiveMethod, JObject.FromObject(result))); } } else { return(SendToCaller(Constants.HubMessages.UnknowErrorMsg, Constants.Enums.MessageReponseKey.Error)); } }
private async Task SendToCaller <T>(T message, Constants.Enums.MessageReponseKey action) { HubResponse <T> result = new HubResponse <T>() { IsSucceed = true, Data = message, ResponseKey = GetResponseKey(action) }; await Clients.Caller.SendAsync(Constants.HubMethods.ReceiveMethod, JObject.FromObject(result).ToString(Newtonsoft.Json.Formatting.None)); }
private void SendToCaller <T>(T message, Constants.Enums.MessageReponseKey action) { HubResponse <T> result = new HubResponse <T>() { IsSucceed = true, Data = message, ResponseKey = GetResponseKey(action) }; Clients.Caller.SendAsync(Constants.HubMethods.ReceiveMethod, JObject.FromObject(result)); }
private void SendToAll <T>(T message, Constants.Enums.MessageReponseKey action, bool isMySelf) { HubResponse <T> result = new HubResponse <T>() { IsSucceed = true, Data = message, ResponseKey = GetResponseKey(action) }; if (isMySelf) { Clients.All.SendAsync(Constants.HubMethods.ReceiveMethod, result); } else { Clients.Others.SendAsync(Constants.HubMethods.ReceiveMethod, result); } }
private async Task SendToAll <T>(T message, Constants.Enums.MessageReponseKey action, bool isMySelf) { HubResponse <T> result = new HubResponse <T>() { IsSucceed = true, Data = message, ResponseKey = GetResponseKey(action) }; if (isMySelf) { await Clients.All.SendAsync(Constants.HubMethods.ReceiveMethod, JObject.FromObject(result).ToString(Newtonsoft.Json.Formatting.None)); } else { await Clients.Others.SendAsync(Constants.HubMethods.ReceiveMethod, JObject.FromObject(result).ToString(Newtonsoft.Json.Formatting.None)); } }
private void SendToGroup <T>(T message, Constants.Enums.MessageReponseKey action, string groupName, bool isMySelf) { if (!string.IsNullOrEmpty(groupName)) { HubResponse <T> result = new HubResponse <T>() { IsSucceed = true, Data = message, ResponseKey = GetResponseKey(action) }; if (isMySelf) { Clients.Group(groupName).SendAsync(Constants.HubMethods.ReceiveMethod, JObject.FromObject(result)); } else { Clients.OthersInGroup(groupName).SendAsync(Constants.HubMethods.ReceiveMethod, JObject.FromObject(result)); } } }