mraow/proto/chat.proto

50 lines
964 B
Protocol Buffer
Raw Normal View History

2023-05-05 01:57:10 +00:00
syntax = "proto3";
2023-05-08 20:14:24 +00:00
package chat;
import "google/protobuf/empty.proto";
2023-05-05 01:57:10 +00:00
message ChatMessage {
2023-05-09 09:31:46 +00:00
string messageId = 1;
string fromUserId = 2;
string toUserId = 3;
string toRoomId = 4;
string content = 5;
2023-05-05 01:57:10 +00:00
}
2023-05-09 17:49:30 +00:00
message Room { string name = 1; }
2023-05-09 07:15:01 +00:00
2023-05-09 09:31:46 +00:00
message UserList { repeated User users = 1; }
2023-05-09 08:14:54 +00:00
2023-05-09 17:49:30 +00:00
message RoomList { repeated Room rooms = 1; }
2023-05-08 20:14:24 +00:00
2023-05-09 17:49:30 +00:00
message User {
string userId = 1;
string username = 2;
}
2023-05-08 20:14:24 +00:00
2023-05-09 09:31:46 +00:00
// RPC Messages
2023-05-09 17:49:30 +00:00
message ReceiveMsgsRequest { string userId = 1; }
2023-05-09 09:43:47 +00:00
message RoomActionResponse {}
2023-05-08 20:14:24 +00:00
2023-05-09 09:31:46 +00:00
message RoomAction {
string roomId = 1;
string userId = 2;
string action = 3;
}
2023-05-09 07:15:01 +00:00
service Chat {
2023-05-09 09:31:46 +00:00
// Rooms
2023-05-09 16:37:52 +00:00
rpc roomAction(RoomAction) returns (RoomActionResponse) {}
2023-05-09 09:31:46 +00:00
// Messages
2023-05-09 07:15:01 +00:00
rpc sendMsg(ChatMessage) returns (google.protobuf.Empty) {}
2023-05-09 17:49:30 +00:00
rpc receiveMsgs(ReceiveMsgsRequest) returns (stream ChatMessage) {}
2023-05-09 08:14:54 +00:00
2023-05-09 09:31:46 +00:00
// List
2023-05-09 08:14:54 +00:00
rpc listRooms(google.protobuf.Empty) returns (RoomList) {}
2023-05-09 07:15:01 +00:00
rpc getAllUsers(google.protobuf.Empty) returns (UserList) {}
2023-05-09 16:37:52 +00:00
}