注解优化,grpc开发
This commit is contained in:
36
zyplayer-doc-grpc/src/main/proto/HelloWorld.proto
Normal file
36
zyplayer-doc-grpc/src/main/proto/HelloWorld.proto
Normal file
@@ -0,0 +1,36 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package helloworld;
|
||||
|
||||
import "google/protobuf/empty.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
||||
option java_multiple_files = true;
|
||||
option java_package = "com.zyplayer.doc.grpc.proto";
|
||||
option java_outer_classname = "HelloWorldProto";
|
||||
|
||||
// The greeting service definition.
|
||||
service ZyplayerGreeter {
|
||||
// Sends a greeting
|
||||
rpc sayHello (HelloRequest) returns (HelloResponse) {}
|
||||
|
||||
// Sends the current time
|
||||
rpc sayTime (google.protobuf.Empty) returns (TimeResponse) {}
|
||||
}
|
||||
|
||||
// The request message containing the user's name.
|
||||
message HelloRequest {
|
||||
string name = 1;
|
||||
string content = 2;
|
||||
int32 time = 3;
|
||||
}
|
||||
|
||||
// The response message containing the greetings
|
||||
message HelloResponse {
|
||||
string message = 1;
|
||||
}
|
||||
|
||||
// The response message containing the time
|
||||
message TimeResponse {
|
||||
google.protobuf.Timestamp time = 1;
|
||||
}
|
||||
34
zyplayer-doc-grpc/src/main/proto/ZyplayerChat.proto
Normal file
34
zyplayer-doc-grpc/src/main/proto/ZyplayerChat.proto
Normal file
@@ -0,0 +1,34 @@
|
||||
syntax = "proto3";
|
||||
option java_outer_classname = "ChatProto";
|
||||
option java_package = "com.zyplayer.doc.grpc.proto";
|
||||
import "google/protobuf/empty.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
package wechat;
|
||||
option java_multiple_files = true;
|
||||
service ZyplayerChat {
|
||||
// 处理请求
|
||||
rpc sendText (ChatMsg) returns (ChatMsg) {}
|
||||
|
||||
rpc sendImage (ChatMsg) returns (ChatMsg) {}
|
||||
}
|
||||
// 完整的grpc结构体
|
||||
message ChatMsg {
|
||||
BaseMsg baseMsg = 1;
|
||||
string token = 2;
|
||||
string version = 3;
|
||||
int32 timeStamp = 4;
|
||||
string iP = 5;
|
||||
}
|
||||
// 请求消息结构体
|
||||
message BaseMsg {
|
||||
int32 ret = 1;
|
||||
int32 cmd = 2;
|
||||
User user = 3;
|
||||
}
|
||||
// 用户结构体
|
||||
message User {
|
||||
int64 uin = 1;
|
||||
bytes cookies = 2;
|
||||
bytes sessionKey = 3;
|
||||
bytes nickname = 4;
|
||||
}
|
||||
Reference in New Issue
Block a user