-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgateway.proto
More file actions
105 lines (90 loc) · 4.33 KB
/
gateway.proto
File metadata and controls
105 lines (90 loc) · 4.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
syntax = "proto3";
package gateway;
option go_package = "github.com/dollarkillerx/im-system/api/proto/gateway;gatewaypb";
import "google/protobuf/struct.proto";
// GatewayService 网关服务
// Gateway service for real-time bidirectional communication
service GatewayService {
// Connect 建立双向流连接 / Establish bidirectional streaming connection
rpc Connect(stream GatewayMessage) returns (stream GatewayMessage);
// Send 发送消息 (单次调用) / Send message (unary call)
rpc Send(SendRequest) returns (SendResponse);
// Sync 同步消息 / Sync messages
rpc Sync(SyncRequest) returns (SyncResponse);
}
// MessageType 消息类型枚举
// Message type enumeration for gateway communication
enum MessageType {
PING = 0; // 心跳ping / Heartbeat ping
PONG = 1; // 心跳pong / Heartbeat pong
AUTH = 2; // 认证消息 / Authentication message
CHAT = 3; // 聊天消息 / Chat message
NOTIFICATION = 4; // 通知消息 / Notification message
ACK = 5; // 确认消息 / Acknowledgment message
ERROR = 6; // 错误消息 / Error message
TYPING = 7; // 正在输入状态 / Typing status
READ_RECEIPT = 8; // 已读回执 / Read receipt
PRESENCE = 9; // 在线状态 / Presence status
}
// GatewayMessage 网关消息 (用于双向流通信)
// Gateway message (for bidirectional streaming communication)
message GatewayMessage {
MessageType type = 1; // 消息类型 / Message type
google.protobuf.Struct payload = 2; // 消息负载 (JSON格式) / Message payload (JSON format)
int64 timestamp = 3; // 时间戳 / Timestamp
optional string msg_id = 4; // 消息ID (可选) / Message ID (optional)
optional int32 error_code = 5; // 错误代码 (仅ERROR类型) / Error code (for ERROR type only)
optional string error_msg = 6; // 错误消息 (仅ERROR类型) / Error message (for ERROR type only)
}
// SendRequest 发送消息请求 (通过网关)
// Send message request (via gateway)
message SendRequest {
int64 conv_id = 1; // 会话ID / Conversation ID
string conv_type = 2; // 会话类型 / Conversation type
google.protobuf.Struct body = 3; // 消息体 / Message body
optional string reply_to = 4; // 回复的消息ID / Reply to message ID
repeated int64 mentions = 5; // @提到的用户列表 / Mentioned users
}
// SendResponse 发送消息响应
// Send message response
message SendResponse {
string msg_id = 1; // 消息ID / Message ID
int64 seq = 2; // 消息序列号 / Message sequence number
int64 created_at = 3; // 创建时间 / Creation time
}
// SyncRequest 同步消息请求
// Sync messages request
message SyncRequest {
repeated ConvSync conversations = 1; // 需要同步的会话列表 / List of conversations to sync
}
// ConvSync 会话同步信息
// Conversation sync information
message ConvSync {
int64 conv_id = 1; // 会话ID / Conversation ID
int64 since_seq = 2; // 从此序列号之后开始同步 / Sync from this sequence number onwards
}
// SyncResponse 同步消息响应
// Sync messages response
message SyncResponse {
repeated ConvMessages conv_messages = 1; // 各会话的消息列表 / Messages for each conversation
}
// ConvMessages 会话消息集合
// Conversation messages collection
message ConvMessages {
int64 conv_id = 1; // 会话ID / Conversation ID
repeated ChatMessage messages = 2; // 消息列表 / Message list
bool has_more = 3; // 是否还有更多消息 / Whether there are more messages
}
// ChatMessage 聊天消息
// Chat message
message ChatMessage {
string msg_id = 1; // 消息ID / Message ID
int64 conv_id = 2; // 会话ID / Conversation ID
int64 seq = 3; // 消息序列号 / Message sequence number
int64 sender_id = 4; // 发送者ID / Sender ID
string conv_type = 5; // 会话类型 / Conversation type
google.protobuf.Struct body = 6; // 消息体 / Message body
optional string reply_to = 7; // 回复的消息ID / Reply to message ID
repeated int64 mentions = 8; // @提到的用户 / Mentioned users
int64 created_at = 9; // 创建时间 / Creation time
}