syntax = "proto3";

option csharp_namespace = "JT808.Gateway.GrpcService";

package JT808GatewayGrpc;

service JT808Gateway{
	// 会话服务-获取会话服务集合
	rpc GetTcpSessionAll(Empty) returns (TcpSessionInfoReply);
	// 会话服务-获取会话总数
	rpc GetTcpSessionCount(Empty) returns (SessionCountReply);
	// 会话服务-通过设备终端号获取当前会话信息
	rpc GetTcpSessionByTerminalPhoneNo(SessionRequest) returns (SessionInfo); 
	// 会话服务-通过设备终端号移除对应会话
	rpc RemoveSessionByTerminalPhoneNo(SessionRemoveRequest) returns (SessionRemoveReply);
	// 统一下发信息
	rpc UnificationSend(UnificationSendRequest) returns (UnificationSendReply);
	// 获取Tcp包计数器
	rpc GetTcpAtomicCounter(Empty) returns (TcpAtomicCounterReply);
	// 会话服务-获取会话服务集合
	rpc GetUdpSessionAll(Empty) returns (UdpSessionInfoReply);
	// 获取Udp包计数器
	rpc GetUdpAtomicCounter(Empty) returns (UdpAtomicCounterReply);
}

message Empty{}

message TcpSessionInfoReply{
	repeated SessionInfo TcpSessions=1;
}
message SessionRequest{
	string TerminalPhoneNo=1;
}
message SessionCountReply{
	int64 Count=1;
}
message UdpSessionInfoReply{
	repeated SessionInfo UdpSessions=1;
}

message SessionInfo{
	string StartTime=1;
	string LastActiveTime=2;
	string TerminalPhoneNo=3;
	string RemoteAddressIP=4;
}

message SessionRemoveRequest{
	string TerminalPhoneNo=1; 
}

message SessionRemoveReply{
	bool Success = 1;
}

message UnificationSendRequest{
	string TerminalPhoneNo=1;
	bytes Data=2;
}

message UnificationSendReply{
	bool Success = 1;
}

message TcpAtomicCounterReply{
	int64 MsgSuccessCount=1;
	int64 MsgFailCount=2;
}

message UdpAtomicCounterReply{
	int64 MsgSuccessCount=1;
	int64 MsgFailCount=2;
}