syntax = "proto3";

package demo.cmd;

option java_package = "com.huangzj.cmd.gen";
option java_multiple_files = true;


enum Service1_Method{
  Default1 = 0;
  Method1 = 1;
}


enum Service2_Method{
  Default2 = 0;
  Method2 = 1;
}


enum Service3_Method{
  Default3 = 0;
  Method3 = 1;
}

/** 区服 ↔ 跨服链路控制（注册、心跳），不经客户端 TCP。 */
enum Service4_Method {
  Default4 = 0;
  Register = 1;
  Heartbeat = 2;
}

service Service1Service {
  rpc GetUser (CmdEchoCts) returns (CmdEchoStc);
}


message CmdRpcEnvelope {
  uint32 service_id = 1;
  uint32 method_id = 2;
  bytes payload = 3;
  int32 cross_ret = 4;
  /** 区服↔跨服链路上对齐请求与响应；客户端 TCP 可保持默认 0。 */
  uint32 link_seq = 5;
}

message CmdEchoCts {
  string text = 1;
}

message CmdEchoStc {
  string text = 1;
  int64 server_time_ms = 2;
}

message CrossForwardCts {
  string trace = 1;
}

message CrossForwardStc {
  string trace = 1;
  int64 cross_time_ms = 2;
}

message CrossProxyCts {
  string trace = 1;
}

message CrossProxyStc {
  string trace = 1;
  int64 cross_time_ms = 2;
  /** 路径2：区服在跨服返回后再追加的说明，证明「经区服二次处理」。 */
  string server_note = 3;
}

message CrossLinkRegisterCts {
  string server_id = 1;
  string token = 2;
}

message CrossLinkRegisterStc {
  bool ok = 1;
  string message = 2;
}

message CrossLinkHeartbeatCts {
  int64 client_time_ms = 1;
}

message CrossLinkHeartbeatStc {
  int64 client_time_ms = 1;
  int64 cross_time_ms = 2;
}
