⚡ 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.Shared.Models;
|
||||
using DysonNetwork.Shared.Proto;
|
||||
using Google.Protobuf.Collections;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using Grpc.Core;
|
||||
|
||||
@@ -44,7 +45,7 @@ public class RingServiceGrpc(
|
||||
}
|
||||
|
||||
public override Task<Empty> PushWebSocketPacketToDevice(PushWebSocketPacketToDeviceRequest request,
|
||||
ServerCallContext context)
|
||||
ServerCallContext context)
|
||||
{
|
||||
var packet = Shared.Models.WebSocketPacket.FromProtoValue(request.Packet);
|
||||
|
||||
@@ -139,10 +140,24 @@ public class RingServiceGrpc(
|
||||
{
|
||||
GetWebsocketConnectionStatusRequest.IdOneofCase.DeviceId =>
|
||||
WebSocketService.GetDeviceIsConnected(request.DeviceId),
|
||||
GetWebsocketConnectionStatusRequest.IdOneofCase.UserId => WebSocketService.GetAccountIsConnected(Guid.Parse(request.UserId)),
|
||||
GetWebsocketConnectionStatusRequest.IdOneofCase.UserId => WebSocketService.GetAccountIsConnected(
|
||||
Guid.Parse(request.UserId)),
|
||||
_ => false
|
||||
};
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -12,117 +12,126 @@ import "account.proto";
|
||||
|
||||
// RingService provides methods to send various types of notifications.
|
||||
service RingService {
|
||||
// Sends an email.
|
||||
rpc SendEmail(SendEmailRequest) returns (google.protobuf.Empty) {}
|
||||
// Sends an email.
|
||||
rpc SendEmail(SendEmailRequest) returns (google.protobuf.Empty) {}
|
||||
|
||||
// Pushes a packet to a user via WebSocket.
|
||||
rpc PushWebSocketPacket(PushWebSocketPacketRequest) returns (google.protobuf.Empty) {}
|
||||
// Pushes a packet to a user via WebSocket.
|
||||
rpc PushWebSocketPacket(PushWebSocketPacketRequest) returns (google.protobuf.Empty) {}
|
||||
|
||||
// Pushes a packet to a list of users via WebSocket.
|
||||
rpc PushWebSocketPacketToUsers(PushWebSocketPacketToUsersRequest) returns (google.protobuf.Empty) {}
|
||||
// Pushes a packet to a list of users via WebSocket.
|
||||
rpc PushWebSocketPacketToUsers(PushWebSocketPacketToUsersRequest) returns (google.protobuf.Empty) {}
|
||||
|
||||
// Pushes a packet to a device via WebSocket.
|
||||
rpc PushWebSocketPacketToDevice(PushWebSocketPacketToDeviceRequest) returns (google.protobuf.Empty) {}
|
||||
// Pushes a packet to a device via WebSocket.
|
||||
rpc PushWebSocketPacketToDevice(PushWebSocketPacketToDeviceRequest) returns (google.protobuf.Empty) {}
|
||||
|
||||
// Pushes a packet to a list of devices via WebSocket.
|
||||
rpc PushWebSocketPacketToDevices(PushWebSocketPacketToDevicesRequest) returns (google.protobuf.Empty) {}
|
||||
// Pushes a packet to a list of devices via WebSocket.
|
||||
rpc PushWebSocketPacketToDevices(PushWebSocketPacketToDevicesRequest) returns (google.protobuf.Empty) {}
|
||||
|
||||
// Sends a push notification to a user.
|
||||
rpc SendPushNotificationToUser(SendPushNotificationToUserRequest) returns (google.protobuf.Empty) {}
|
||||
// Sends a push notification to a user.
|
||||
rpc SendPushNotificationToUser(SendPushNotificationToUserRequest) returns (google.protobuf.Empty) {}
|
||||
|
||||
// Sends a push notification to a list of users.
|
||||
rpc SendPushNotificationToUsers(SendPushNotificationToUsersRequest) returns (google.protobuf.Empty) {}
|
||||
// Sends a push notification to a list of users.
|
||||
rpc SendPushNotificationToUsers(SendPushNotificationToUsersRequest) returns (google.protobuf.Empty) {}
|
||||
|
||||
// Unsubscribes a device from push notifications.
|
||||
rpc UnsubscribePushNotifications(UnsubscribePushNotificationsRequest) returns (google.protobuf.Empty) {}
|
||||
// Unsubscribes a device from push notifications.
|
||||
rpc UnsubscribePushNotifications(UnsubscribePushNotificationsRequest) returns (google.protobuf.Empty) {}
|
||||
|
||||
// Gets the WebSocket connection status for a device or user.
|
||||
rpc GetWebsocketConnectionStatus(GetWebsocketConnectionStatusRequest) returns (GetWebsocketConnectionStatusResponse) {}
|
||||
// Gets the WebSocket connection status for a device or user.
|
||||
rpc GetWebsocketConnectionStatus(GetWebsocketConnectionStatusRequest) returns (GetWebsocketConnectionStatusResponse) {}
|
||||
|
||||
rpc GetWebsocketConnectionStatusBatch(GetWebsocketConnectionStatusBatchRequest) returns (GetWebsocketConnectionStatusBatchResponse) {}
|
||||
}
|
||||
|
||||
// Represents an email message.
|
||||
message EmailMessage {
|
||||
string to_name = 1;
|
||||
string to_address = 2;
|
||||
string subject = 3;
|
||||
string body = 4;
|
||||
string to_name = 1;
|
||||
string to_address = 2;
|
||||
string subject = 3;
|
||||
string body = 4;
|
||||
}
|
||||
|
||||
message SendEmailRequest {
|
||||
EmailMessage email = 1;
|
||||
EmailMessage email = 1;
|
||||
}
|
||||
|
||||
// Represents a WebSocket packet.
|
||||
message WebSocketPacket {
|
||||
string type = 1;
|
||||
bytes data = 2;
|
||||
google.protobuf.StringValue error_message = 3;
|
||||
string type = 1;
|
||||
bytes data = 2;
|
||||
google.protobuf.StringValue error_message = 3;
|
||||
}
|
||||
|
||||
message PushWebSocketPacketRequest {
|
||||
string user_id = 1;
|
||||
WebSocketPacket packet = 2;
|
||||
string user_id = 1;
|
||||
WebSocketPacket packet = 2;
|
||||
}
|
||||
|
||||
message PushWebSocketPacketToUsersRequest {
|
||||
repeated string user_ids = 1;
|
||||
WebSocketPacket packet = 2;
|
||||
repeated string user_ids = 1;
|
||||
WebSocketPacket packet = 2;
|
||||
}
|
||||
|
||||
message PushWebSocketPacketToDeviceRequest {
|
||||
string device_id = 1;
|
||||
WebSocketPacket packet = 2;
|
||||
string device_id = 1;
|
||||
WebSocketPacket packet = 2;
|
||||
}
|
||||
|
||||
message PushWebSocketPacketToDevicesRequest {
|
||||
repeated string device_ids = 1;
|
||||
WebSocketPacket packet = 2;
|
||||
repeated string device_ids = 1;
|
||||
WebSocketPacket packet = 2;
|
||||
}
|
||||
|
||||
// Represents a push notification.
|
||||
message PushNotification {
|
||||
string topic = 1;
|
||||
string title = 2;
|
||||
string subtitle = 3;
|
||||
string body = 4;
|
||||
optional bytes meta = 5;
|
||||
optional string action_uri = 6;
|
||||
bool is_silent = 7;
|
||||
bool is_savable = 8;
|
||||
string topic = 1;
|
||||
string title = 2;
|
||||
string subtitle = 3;
|
||||
string body = 4;
|
||||
optional bytes meta = 5;
|
||||
optional string action_uri = 6;
|
||||
bool is_silent = 7;
|
||||
bool is_savable = 8;
|
||||
}
|
||||
|
||||
message SendPushNotificationToUserRequest {
|
||||
string user_id = 1;
|
||||
PushNotification notification = 2;
|
||||
string user_id = 1;
|
||||
PushNotification notification = 2;
|
||||
}
|
||||
|
||||
message SendPushNotificationToUsersRequest {
|
||||
repeated string user_ids = 1;
|
||||
PushNotification notification = 2;
|
||||
repeated string user_ids = 1;
|
||||
PushNotification notification = 2;
|
||||
}
|
||||
|
||||
message UnsubscribePushNotificationsRequest {
|
||||
string device_id = 1;
|
||||
string device_id = 1;
|
||||
}
|
||||
|
||||
message GetWebsocketConnectionStatusRequest {
|
||||
oneof id {
|
||||
string device_id = 1;
|
||||
string user_id = 2;
|
||||
}
|
||||
oneof id {
|
||||
string device_id = 1;
|
||||
string user_id = 2;
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
rpc ReceiveWebSocketPacket(ReceiveWebSocketPacketRequest) returns (google.protobuf.Empty) {}
|
||||
rpc ReceiveWebSocketPacket(ReceiveWebSocketPacketRequest) returns (google.protobuf.Empty) {}
|
||||
}
|
||||
|
||||
message ReceiveWebSocketPacketRequest {
|
||||
WebSocketPacket packet = 1;
|
||||
Account account = 2;
|
||||
string device_id = 3;
|
||||
WebSocketPacket packet = 1;
|
||||
Account account = 2;
|
||||
string device_id = 3;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user