public async Task SubscribeToRoomsUpdatesAsync(string userId, string connectionId, params Room[] rooms) { await GrpcCallerService.CallService(_urls.GrpcNotifications, async channel => { var client = new NotificationsGrpc.NotificationsGrpcClient(channel); var request = new RoomsUpdatesRequest { UserId = userId, ConnectionId = connectionId }; foreach (var room in rooms) { var roomModel = new GrpcNotifcations.Room { Id = room.Id }; roomModel.MembersIds.AddRange(room.MembersIds); request.Rooms.Add(roomModel); } await client.SubscribeToRoomsUpdatesAsync(request); }); }
public NotificationsDerived(string address, int delayInMiliseconds = 1000) { GrpcWebHandler handler = new GrpcWebHandler(new HttpClientHandler()); GrpcChannel channel = GrpcChannel.ForAddress(address, new GrpcChannelOptions { HttpClient = new HttpClient(handler) }); _client = new NotificationsGrpc.NotificationsGrpcClient(channel); DelayInMiliseconds = delayInMiliseconds; }
public async Task SubscribeToUsersStatusUpdatesAsync(string userId, string connectionId, params string[] usersIds) { await GrpcCallerService.CallService(_urls.GrpcNotifications, async channel => { var client = new NotificationsGrpc.NotificationsGrpcClient(channel); var request = new ConnectionsUpdatesRequest { UserId = userId, ConnectionId = connectionId }; request.UsersIds.AddRange(usersIds); await client.SubscribeToUsersStatusUpdatesAsync(request); }); }
public static void Initialize(string address, int delayInMiliseconds = 1000) { GrpcWebHandler handler = new GrpcWebHandler(new HttpClientHandler()); GrpcChannel channel = GrpcChannel.ForAddress(address, new GrpcChannelOptions { HttpClient = new HttpClient(handler) }); Client = new NotificationsGrpc.NotificationsGrpcClient(channel); DelayInMiliseconds = delayInMiliseconds; Subscribe(notification => { Notifications.Add(notification); return(null); }); }