commit
e188825429
10 changed files with 436 additions and 0 deletions
@ -0,0 +1,31 @@
|
||||
# IDE ignore |
||||
.idea/ |
||||
*.ipr |
||||
*.iml |
||||
*.iws |
||||
.vscode/ |
||||
.fleet/ |
||||
|
||||
# temp ignore |
||||
*.log |
||||
*.cache |
||||
*.diff |
||||
*.exe |
||||
*.exe~ |
||||
*.patch |
||||
*.tmp |
||||
*.swp |
||||
*.db |
||||
|
||||
# system ignore |
||||
.DS_Store |
||||
Thumbs.db |
||||
|
||||
# build |
||||
/target |
||||
/configs |
||||
/dist |
||||
/tmp |
||||
|
||||
/api/gen |
||||
.back_groups/ |
||||
@ -0,0 +1,54 @@
|
||||
syntax = "proto3"; |
||||
//import "google/protobuf/empty.proto"; |
||||
//import "google/protobuf/wrappers.proto"; |
||||
//import "google/protobuf/type.proto"; |
||||
|
||||
option go_package = "./auth"; |
||||
|
||||
service AuthService { |
||||
// account password login |
||||
rpc Login(ReqLogin) returns(ResLogin); |
||||
|
||||
// verify token validate |
||||
rpc Verify(ReqVerify) returns (Subject); |
||||
|
||||
// registry |
||||
rpc Registry(ReqRegistry) returns (Subject); |
||||
|
||||
// uid registry info |
||||
rpc FindByUid(ReqFindByUid) returns(Subject); |
||||
} |
||||
|
||||
message Subject { |
||||
string uid = 1; |
||||
string username = 2; |
||||
int64 time = 3; // ms |
||||
map<string, string> extra = 4; |
||||
} |
||||
|
||||
message ReqLogin { |
||||
string account = 2; |
||||
string password = 3; |
||||
} |
||||
|
||||
message ResLogin { |
||||
string token = 2; |
||||
// string refreshToken = 3; |
||||
|
||||
Subject subject = 7; |
||||
} |
||||
|
||||
message ReqVerify { |
||||
string token = 2; |
||||
} |
||||
|
||||
message ReqRegistry { |
||||
string account = 1; |
||||
string username = 2; |
||||
string password = 3; |
||||
map<string, string> extra = 4; |
||||
} |
||||
|
||||
message ReqFindByUid { |
||||
string uid = 1; |
||||
} |
||||
@ -0,0 +1,88 @@
|
||||
syntax = "proto3"; |
||||
|
||||
import "google/protobuf/empty.proto"; |
||||
option go_package = "./chat"; |
||||
|
||||
service AuthService { |
||||
rpc Send(ReqSendChat) returns (ResSendChat); |
||||
|
||||
rpc GroupSend(ReqSendGroupChat) returns (ResSendChat); |
||||
|
||||
rpc GroupCreate(ReqGroupCreate) returns (ResGroupCreate); |
||||
|
||||
rpc GroupJoin(ReqGroupJoin) returns (google.protobuf.Empty); |
||||
|
||||
rpc GroupLeave(ReqGroupLeave) returns (google.protobuf.Empty); |
||||
|
||||
rpc GroupKickOut(ReqGroupKickOut) returns (google.protobuf.Empty); |
||||
|
||||
rpc GroupInfo(ReqGroupInfo) returns (ResGroupInfo); |
||||
|
||||
rpc GroupList(ReqGroupList) returns (ResGroupList); |
||||
} |
||||
|
||||
message ChatMessage { |
||||
string sender = 1; |
||||
string content = 7; |
||||
} |
||||
|
||||
message ReqSendChat { |
||||
string receiver = 2; |
||||
string content = 3; // 消息格式化器 [img:img_id][file:file_id]text... |
||||
} |
||||
|
||||
message ReqSendGroupChat { |
||||
string gid = 1; |
||||
string message = 2; |
||||
} |
||||
|
||||
message ResSendChat { |
||||
int32 status = 1; // 1已发送,2已接收 |
||||
string result = 2; |
||||
} |
||||
|
||||
message Group { |
||||
string gid = 1; |
||||
string masterUid = 2; |
||||
int32 userLimit = 3; |
||||
int32 userNum = 4; |
||||
string gname = 5; |
||||
string createUid = 6; |
||||
int64 createAt = 7; |
||||
} |
||||
|
||||
message ReqGroupCreate { |
||||
string gname = 2; |
||||
} |
||||
|
||||
message ResGroupCreate { |
||||
Group group = 1; |
||||
} |
||||
|
||||
message ReqGroupJoin { |
||||
string gid = 1; |
||||
} |
||||
|
||||
message ReqGroupLeave { |
||||
string gid = 1; |
||||
} |
||||
|
||||
message ReqGroupKickOut { |
||||
string gid = 1; |
||||
string uid = 2; |
||||
} |
||||
|
||||
message ReqGroupInfo { |
||||
string gid = 1; |
||||
} |
||||
|
||||
message ResGroupInfo { |
||||
Group group = 1; |
||||
} |
||||
|
||||
message ReqGroupList { |
||||
} |
||||
|
||||
message ResGroupList { |
||||
repeated Group groups = 1; |
||||
} |
||||
@ -0,0 +1,105 @@
|
||||
syntax = "proto3"; |
||||
|
||||
import "google/protobuf/empty.proto"; |
||||
option go_package = "./mahjong"; |
||||
|
||||
service MahjongService { |
||||
|
||||
rpc PlayerOnline(google.protobuf.Empty) returns(ResPlayerOnline); // 登录后初始化玩家信 |
||||
|
||||
rpc PlayerOffline(google.protobuf.Empty) returns(google.protobuf.Empty); // 登 |
||||
|
||||
rpc LobbyView(google.protobuf.Empty) returns(Lobby); |
||||
|
||||
// return tableId |
||||
rpc CreateTable(google.protobuf.Empty) returns(MjTable); |
||||
|
||||
rpc JoinTable(ReqJoinTable) returns(MjTable); |
||||
|
||||
rpc LeaveTable(google.protobuf.Empty) returns(google.protobuf.Empty); |
||||
|
||||
rpc KickoutTable(ReqKickoutTable) returns(google.protobuf.Empty); |
||||
|
||||
rpc ReadyStart(google.protobuf.Empty) returns(google.protobuf.Empty); |
||||
|
||||
rpc CancelReady(google.protobuf.Empty) returns(google.protobuf.Empty); |
||||
|
||||
// 解散牌桌 |
||||
rpc DismissTable(google.protobuf.Empty) returns(google.protobuf.Empty); |
||||
|
||||
rpc GameStart(google.protobuf.Empty) returns(google.protobuf.Empty); |
||||
|
||||
rpc PlayerAction(ReqPlayerAction) returns(google.protobuf.Empty); |
||||
} |
||||
|
||||
message ResPlayerOnline { |
||||
MjPlayer player = 1; |
||||
} |
||||
|
||||
message ReqPlayerAction { |
||||
int32 opt = 1; // 定缺 |
||||
int32 tileLack = 2; // 定缺: 0万 1条 2筒 |
||||
int32 hit = 3; // 出牌 |
||||
} |
||||
|
||||
message ReqJoinTable { |
||||
string tableId = 1; |
||||
} |
||||
|
||||
message ReqKickoutTable { |
||||
string targetUid = 1; |
||||
} |
||||
|
||||
message LobbyTable { |
||||
string tableId = 1; |
||||
int32 playerCount = 2; |
||||
int32 stage = 3; |
||||
} |
||||
|
||||
message Lobby { |
||||
repeated LobbyTable tables = 1; |
||||
} |
||||
|
||||
|
||||
message WinSettle { |
||||
int32 weight = 1; |
||||
string winTypeName = 2; |
||||
repeated string weightNames = 3; |
||||
} |
||||
|
||||
message MjPlayer { |
||||
string playerId = 1; |
||||
string username = 2; |
||||
string avatar = 3; |
||||
int32 status = 4; |
||||
int32 tileLack = 5; // 缺一门 |
||||
int64 coin = 6; |
||||
string tableId = 7; // 玩家当前牌桌id |
||||
repeated int32 mjHand = 8; // 手牌 |
||||
int32 mjDraw = 9; // 摸牌 |
||||
message Peng { |
||||
repeated int32 mj = 1; |
||||
} |
||||
repeated Peng mjPeng = 10; // 碰 |
||||
message Gang{ |
||||
repeated int32 mj = 1; |
||||
} |
||||
repeated Gang mjGang = 11; // 杠 |
||||
repeated int32 opts = 12; // 可操作列表 |
||||
repeated int32 gangTiles = 13; // 可杠牌列表 |
||||
WinSettle winSettle = 18; |
||||
|
||||
// 18: optional i8 direct // 0.东 1.南 2.西 3.北 |
||||
} |
||||
|
||||
message MjTable { |
||||
string tableId = 1; |
||||
string masterId = 2; |
||||
int32 stage = 3; |
||||
int32 gameTimes = 4; |
||||
repeated MjPlayer players = 5; |
||||
repeated int32 playerDirects = 6; // 0.东 1.南 2.西 3.北 |
||||
int32 restTiles = 7;// 剩余牌张数 |
||||
string hitPlayerId = 8; |
||||
repeated int32 hits = 9; |
||||
} |
||||
@ -0,0 +1,70 @@
|
||||
syntax = "proto3"; |
||||
import "google/protobuf/empty.proto"; |
||||
|
||||
option go_package = "./postal"; |
||||
|
||||
service Postal { |
||||
rpc Deliver(ReqDeliver) returns (ResDeliver); |
||||
rpc DeliverBatch(ReqDeliverBatch) returns(ResDeliver); |
||||
rpc DeliverGroup(ReqDeliverGroup) returns(ResDeliver); |
||||
|
||||
rpc GroupCreate(ReqGroupCreate) returns(ResGroupCreate); |
||||
rpc GroupJoin(ReqGroupJoin) returns(google.protobuf.Empty); |
||||
rpc GroupLeave(ReqGroupLeave) returns(google.protobuf.Empty); |
||||
rpc GroupDissolve(ReqGroupDissolve) returns(google.protobuf.Empty); |
||||
} |
||||
|
||||
message Message { |
||||
int64 time = 3; |
||||
int32 svcNo = 4; |
||||
int32 msgNo = 5; |
||||
bytes body = 6; // protobuf bytes |
||||
} |
||||
|
||||
message ReqDeliver { |
||||
string receiver = 1; |
||||
Message msg = 2; |
||||
|
||||
// bool sync = 7; // 是否同步阻塞等待投递结果, 默认false立即返回放到队列消费投递 |
||||
} |
||||
|
||||
message ResDeliver { |
||||
bool ok = 1; |
||||
int32 code = 2; |
||||
string msg = 3; |
||||
} |
||||
|
||||
message ReqDeliverBatch { |
||||
repeated string receivers = 1; |
||||
Message msg = 2; |
||||
} |
||||
|
||||
message ReqDeliverGroup { |
||||
string gid = 1; |
||||
Message msg = 2; |
||||
} |
||||
|
||||
message ReqGroupCreate { |
||||
string gid = 1; // 群id |
||||
map<string, string> tags = 3; // 群标签... |
||||
|
||||
bool persistent = 7; // 群关系是否持久化, 默认否 |
||||
} |
||||
|
||||
message ResGroupCreate { |
||||
string gid = 1; // 群id |
||||
} |
||||
|
||||
message ReqGroupJoin { |
||||
string gid = 1; |
||||
string uid = 2; |
||||
} |
||||
|
||||
message ReqGroupLeave { |
||||
string gid = 1; |
||||
string uid = 2; |
||||
} |
||||
|
||||
message ReqGroupDissolve { |
||||
string gid = 1; |
||||
} |
||||
@ -0,0 +1,6 @@
|
||||
package main |
||||
|
||||
// websocket server with postalService
|
||||
func main() { |
||||
|
||||
} |
||||
@ -0,0 +1,3 @@
|
||||
package sonet |
||||
|
||||
//go:generate protoc --go_out=./api/gen --go-grpc_out=./api/gen ./api/*.proto
|
||||
@ -0,0 +1,16 @@
|
||||
module sonet |
||||
|
||||
go 1.19 |
||||
|
||||
require ( |
||||
google.golang.org/grpc v1.60.1 |
||||
google.golang.org/protobuf v1.32.0 |
||||
) |
||||
|
||||
require ( |
||||
github.com/golang/protobuf v1.5.3 // indirect |
||||
golang.org/x/net v0.16.0 // indirect |
||||
golang.org/x/sys v0.13.0 // indirect |
||||
golang.org/x/text v0.13.0 // indirect |
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 // indirect |
||||
) |
||||
@ -0,0 +1,20 @@
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= |
||||
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= |
||||
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= |
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= |
||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= |
||||
golang.org/x/net v0.16.0 h1:7eBu7KsSvFDtSXUIDbh3aqlK4DPsZ1rByC8PFfBThos= |
||||
golang.org/x/net v0.16.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= |
||||
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= |
||||
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
||||
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= |
||||
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= |
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= |
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 h1:6GQBEOdGkX6MMTLT9V+TjtIRZCw9VPD5Z+yHY9wMgS0= |
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97/go.mod h1:v7nGkzlmW8P3n/bKmWBn2WpBjpOEx8Q6gMueudAmKfY= |
||||
google.golang.org/grpc v1.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU= |
||||
google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM= |
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= |
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= |
||||
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= |
||||
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= |
||||
@ -0,0 +1,43 @@
|
||||
package logic |
||||
|
||||
import ( |
||||
"context" |
||||
"google.golang.org/protobuf/types/known/emptypb" |
||||
"sonet/api/gen/postal" |
||||
) |
||||
|
||||
type PostalServer struct { |
||||
postal.UnimplementedPostalServer |
||||
} |
||||
|
||||
func NewPostalServer() *PostalServer { |
||||
return &PostalServer{} |
||||
} |
||||
|
||||
func (p *PostalServer) Deliver(ctx context.Context, deliver *postal.ReqDeliver) (*postal.ResDeliver, error) { |
||||
return nil, nil |
||||
} |
||||
|
||||
func (p *PostalServer) DeliverBatch(ctx context.Context, batch *postal.ReqDeliverBatch) (*postal.ResDeliver, error) { |
||||
return nil, nil |
||||
} |
||||
|
||||
func (p *PostalServer) DeliverGroup(ctx context.Context, group *postal.ReqDeliverGroup) (*postal.ResDeliver, error) { |
||||
return nil, nil |
||||
} |
||||
|
||||
func (p *PostalServer) GroupCreate(ctx context.Context, create *postal.ReqGroupCreate) (*postal.ResGroupCreate, error) { |
||||
return nil, nil |
||||
} |
||||
|
||||
func (p *PostalServer) GroupJoin(ctx context.Context, join *postal.ReqGroupJoin) (*emptypb.Empty, error) { |
||||
return nil, nil |
||||
} |
||||
|
||||
func (p *PostalServer) GroupLeave(ctx context.Context, leave *postal.ReqGroupLeave) (*emptypb.Empty, error) { |
||||
return nil, nil |
||||
} |
||||
|
||||
func (p *PostalServer) GroupDissolve(ctx context.Context, dissolve *postal.ReqGroupDissolve) (*emptypb.Empty, error) { |
||||
return nil, nil |
||||
} |
||||
Loading…
Reference in new issue