/// <summary> /// Send a list of channels to agent /// </summary> /// <param name="agentLivechatUserId">Agent id</param> /// <param name="connectionId">Agent's connection Id</param> /// <returns>List of channels</returns> public virtual async Task <List <LivechatChannel> > SendChannelListToAgent(string connectionId, string agentLivechatUserId) { var onlineUsers = await userTracker.UsersOnline(); // Removes current user (agent) from this verification onlineUsers = onlineUsers.Where(t => t.LivechatUserId != agentLivechatUserId); // Get agent channels var channels = await uow .GetRepository <ChannelRepository>() .GetAgentChannels(agentLivechatUserId); // Check list of channels and assign HasOnlineUsers when they have online users foreach (var channel in channels) { channel.HasOnlineUsers = onlineUsers.Any(t => t.Channels.Any(c => c.ChannelId == channel.ChannelId) ); } // Send channels list await clientsManager .Client(connectionId) .SendAsync(HubMessages.ACTIVE_CHANNELS, channels); return(channels); }
public async Task SendChatMesssage(string name, string message, IHubCallerClients clients, string callersUserName) { string id = GetConnectionId(name); ChatMessageViewModel model = await GenerateChatMessage(message, name, callersUserName); await clients.Client(id).SendAsync("ReceiveChatMessage", model); }
public static async Task Notify(int eventId) { if (Clients != null) { try { var clients = redisDB.GetAll(); var userConnections = clients.Where(c => c.EventId == eventId).Select(c => c.Connections.Select(i => i.Id)).ToList(); foreach (var connections in userConnections) { foreach (var connectionId in connections) { await Clients.Client(connectionId).SendAsync("ReceiveMessage", "Server", "notify"); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } } }
public Task SendClientMessage(string connectionId, string method, object arg1) { var client = clientsManager.Client(connectionId); if (client == null) { return(Task.CompletedTask); } return(client.SendAsync(method, arg1)); }
public async Task MessageSend(IHubCallerClients clients, chatMessageRequest userInfoRequest) { var response = new chatMessageResponse() { SelfconnetionId = userInfoRequest.SelfconnetionId, MsgType = messageTypes.Person, Message = userInfoRequest.Message }; var outputBuffer = new ArraySegment <byte>(response.ToByteArray(), 0, (int)response.ToByteArray().Length); await clients.Client(userInfoRequest.OtherconnetionId).SendAsync("person", outputBuffer); }
public CustomerHubRules( LivechatRules livechatRules, IGroupManager groupManager, HubCallerContext context, IHubCallerClients clientsManager, IChatConversationHandler conversationHandler ) { this.livechatRules = livechatRules ?? throw new ArgumentNullException(nameof(livechatRules)); this.groupManager = groupManager ?? throw new ArgumentNullException(nameof(groupManager)); this.context = context ?? throw new ArgumentNullException(nameof(context)); this.clientsManager = clientsManager ?? throw new ArgumentNullException(nameof(clientsManager)); this.conversationHandler = conversationHandler ?? throw new ArgumentNullException(nameof(conversationHandler)); currentUser = clientsManager.Client(context.ConnectionId); }
public async Task <string> ForwardAsync(IHubCallerClients clients, Message message) { if (this._clientMap.TryGetValue(message.Destinatario, out string connId)) { var crr = new ClientRequestReply(clients.Client(connId)); try { this._pendingRequests.TryAdd(crr.Uid, crr); return(await crr.SendRequest(message)); } finally { this._pendingRequests.TryRemove(crr.Uid, out _); } } else { throw new KeyNotFoundException(); } }
public async Task SetColor() { Random rand = new Random(); int firstIndex = rand.Next(0, 2); this.TurnIndex = firstIndex; if (firstIndex == 0) { this.Black = this.PlayerList[0]; this.White = this.PlayerList[1]; } else { this.Black = this.PlayerList[1]; this.White = this.PlayerList[0]; } await Clients.Client(this.Black.ConnectionId).SendAsync("MyColor", "black"); await Clients.Client(this.White.ConnectionId).SendAsync("MyColor", "white"); }
public dynamic Client(string connectionId) => new DynamicClientProxy(_clients.Client(connectionId));
public void update(IHubCallerClients context, string jsonMap, string jsonPlayers, string jsonScoreboard, int roundEnded) { context.Client(id).SendCoreAsync("SendData", new object[] { jsonPlayers, jsonMap, health, jsonScoreboard, roundEnded }); //context.Client(id).SendAsync("SendData", jsonPlayers, jsonMap, health); }
public static async void SendSignal(string Token) { await Client.Client(ClientList[ObjectId.Parse(Token)]).SendAsync("Notifaction"); }
public TTo Client(string connectionId) { return(_src.Client(connectionId)); }
public static async void SendMessangeToUser(string userid, string message) { await sClients.Client(ChatUser[userid]).SendAsync("ReceiveMessage", message); }
static IClientProxy GetOtherPlayerClient(IHubCallerClients Clients, Guid userId) { var otherPlayer = Handler.GetGame(userId).GetOtherPlayer(userId); return(Clients.Client(otherPlayer.ConnectionId)); }
public async Task OnNextAsync(Message item, StreamSequenceToken token = null) { await _clients.Client(_connectionId).SendAsync("send.message", _channelName, item); }
public T Client(string connectionId) { return(TypedClientBuilder <T> .Build(_hubClients.Client(connectionId))); }
public async Task SendGameState(string name, GameStateModel game, IHubCallerClients clients) { string id = GetConnectionId(name); await clients.Client(id).SendAsync("ReceiveGameState", game); }