⚡ Ring service now provide batch variant of get websocket status endpoint
This commit is contained in:
@@ -2,6 +2,7 @@ using DysonNetwork.Ring.Connection;
|
|||||||
using DysonNetwork.Ring.Notification;
|
using DysonNetwork.Ring.Notification;
|
||||||
using DysonNetwork.Shared.Models;
|
using DysonNetwork.Shared.Models;
|
||||||
using DysonNetwork.Shared.Proto;
|
using DysonNetwork.Shared.Proto;
|
||||||
|
using Google.Protobuf.Collections;
|
||||||
using Google.Protobuf.WellKnownTypes;
|
using Google.Protobuf.WellKnownTypes;
|
||||||
using Grpc.Core;
|
using Grpc.Core;
|
||||||
|
|
||||||
@@ -139,10 +140,24 @@ public class RingServiceGrpc(
|
|||||||
{
|
{
|
||||||
GetWebsocketConnectionStatusRequest.IdOneofCase.DeviceId =>
|
GetWebsocketConnectionStatusRequest.IdOneofCase.DeviceId =>
|
||||||
WebSocketService.GetDeviceIsConnected(request.DeviceId),
|
WebSocketService.GetDeviceIsConnected(request.DeviceId),
|
||||||
GetWebsocketConnectionStatusRequest.IdOneofCase.UserId => WebSocketService.GetAccountIsConnected(Guid.Parse(request.UserId)),
|
GetWebsocketConnectionStatusRequest.IdOneofCase.UserId => WebSocketService.GetAccountIsConnected(
|
||||||
|
Guid.Parse(request.UserId)),
|
||||||
_ => false
|
_ => false
|
||||||
};
|
};
|
||||||
|
|
||||||
return Task.FromResult(new GetWebsocketConnectionStatusResponse { IsConnected = isConnected });
|
return Task.FromResult(new GetWebsocketConnectionStatusResponse { IsConnected = isConnected });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override Task<GetWebsocketConnectionStatusBatchResponse> GetWebsocketConnectionStatusBatch(
|
||||||
|
GetWebsocketConnectionStatusBatchRequest request, ServerCallContext context)
|
||||||
|
{
|
||||||
|
var resp = new GetWebsocketConnectionStatusBatchResponse();
|
||||||
|
foreach (var id in request.UsersId)
|
||||||
|
{
|
||||||
|
var gid = Guid.Parse(id);
|
||||||
|
resp.IsConnected[id] = WebSocketService.GetAccountIsConnected(gid);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Task.FromResult(resp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -38,6 +38,8 @@ service RingService {
|
|||||||
|
|
||||||
// Gets the WebSocket connection status for a device or user.
|
// Gets the WebSocket connection status for a device or user.
|
||||||
rpc GetWebsocketConnectionStatus(GetWebsocketConnectionStatusRequest) returns (GetWebsocketConnectionStatusResponse) {}
|
rpc GetWebsocketConnectionStatus(GetWebsocketConnectionStatusRequest) returns (GetWebsocketConnectionStatusResponse) {}
|
||||||
|
|
||||||
|
rpc GetWebsocketConnectionStatusBatch(GetWebsocketConnectionStatusBatchRequest) returns (GetWebsocketConnectionStatusBatchResponse) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Represents an email message.
|
// Represents an email message.
|
||||||
@@ -116,6 +118,13 @@ message GetWebsocketConnectionStatusResponse {
|
|||||||
bool is_connected = 1;
|
bool is_connected = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message GetWebsocketConnectionStatusBatchRequest {
|
||||||
|
repeated string users_id = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetWebsocketConnectionStatusBatchResponse {
|
||||||
|
map<string, bool> is_connected = 1;
|
||||||
|
}
|
||||||
|
|
||||||
service RingHandlerService {
|
service RingHandlerService {
|
||||||
rpc ReceiveWebSocketPacket(ReceiveWebSocketPacketRequest) returns (google.protobuf.Empty) {}
|
rpc ReceiveWebSocketPacket(ReceiveWebSocketPacketRequest) returns (google.protobuf.Empty) {}
|
||||||
|
|||||||
Reference in New Issue
Block a user