diff --git a/README.md b/README.md index f2eeec72dd61530057b7124f90d1e8bb6f67f353..1a050e44e2c9c9db1710464211a3b393cea2bc4c 100644 --- a/README.md +++ b/README.md @@ -79,23 +79,23 @@ func main() { 除 toClientId,fromClientId,channel外 其它都可以随意定议,增减都可以。 ```$xslt + message SendMsg { int32 cmd =1; - int64 timestamp = 2; + int64 timestamp = 2; //消息发送时间 string fromClientId =3; //指令消息的来源。发送者的连接ID string toClientId = 4; //指令消息的接收者。发送给对应的客户端连接ID bytes cmdData =5; //对应指令的CmdData1的protobuf的message - string msgId=6; - int32 status=7; //消息发送响应状态 - string Msg=8; //消息发送字符串内容 - string cmdkey=9; //用于区分同一cmd多条指令的key 方便api调用针对同一指令不同回调的处理 - int32 priority=10; //用于处理指令队列的优先级的权重值 - int32 localId = 11; //用于手机本地数据库存储标志, 服务端不用管 - string pageKey = 12; //用于页面发送指令和接收的指令相对应 如发送cmd2003和收到的cmd1000对应 - repeated string channel = 13; //指定需要广播的频道,可以指定一个或多个频道 - string pageId = 14; //用于前端存储处理 + int32 status=6; //消息发送响应状态 + int32 priority=7; //用于处理指令队列的优先级的权重值 + int32 localId = 8; //客户端标识消息的id,主要区分相同cmd的不同消息,方便收到回复分发处理等效果 + int64 serverId = 9; //服务端发送消息的ID,主要区分相同cmd的不同消息,方便服务端收到回复分发处理等效果 + repeated string channel = 10; //指定需要广播的频道,可以指定一个或多个频道 + string msg =11; //一般用于json数据传递,或消息发送响应内容 + string Desc=12; //消息介绍内容,或其它数据 } + ``` 作者很懒惰!! diff --git a/cmd.proto b/cmd.proto index 11f4273d6ca5a40ecf47cd61386ed53651daf295..2100b76e699c7787185b68438795b1e37d854c10 100644 --- a/cmd.proto +++ b/cmd.proto @@ -12,10 +12,28 @@ message SendMsg { string callbackMsg=8; //消息发送响应内容 string cmdkey=9; //用于区分同一cmd多条指令的key 方便api调用针对同一指令不同回调的处理 int32 priority=10; //用于处理指令队列的优先级的权重值 - int32 localId = 11; //用于手机本地数据库存储标志, 服务端不用管 + int32 localId = 11; //客户端标识消息的id,主要区分相同cmd的不同消息,方便收到回复分发处理等效果 string pageKey = 12; //用于页面发送指令和接收的指令相对应 如发送cmd2003和收到的cmd1000对应 repeated string channel = 13; //指定需要广播的频道,可以指定一个或多个频道 string pageId = 14; //用于前端存储处理 string msg =15; //一般用于json数据传递 - string Desc=16; + string Desc=16; //消息介绍内容,或其它数据 } + +/* + +message SendMsg { + int32 cmd =1; + int64 timestamp = 2; //消息发送时间 + string fromClientId =3; //指令消息的来源。发送者的连接ID + string toClientId = 4; //指令消息的接收者。发送给对应的客户端连接ID + bytes cmdData =5; //对应指令的CmdData1的protobuf的message + int32 status=6; //消息发送响应状态 + int32 priority=7; //用于处理指令队列的优先级的权重值 + int32 localId = 8; //客户端标识消息的id,主要区分相同cmd的不同消息,方便收到回复分发处理等效果 + int64 serverId = 9; //服务端发送消息的ID,主要区分相同cmd的不同消息,方便服务端收到回复分发处理等效果 + repeated string channel = 10; //指定需要广播的频道,可以指定一个或多个频道 + string msg =11; //一般用于json数据传递,或消息发送响应内容 + string Desc=12; //消息介绍内容,或其它数据 +} +*/ diff --git a/go.mod b/go.mod index 531195d647da4698eebc54d84548b38a02ba6440..129c0792bc8bd9d0235b66a264efcc94f3c379e5 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,9 @@ module gitee.com/rczweb/wsPool -require github.com/gorilla/websocket v1.4.1 - require ( github.com/gogo/protobuf v1.3.1 github.com/golang/protobuf v1.3.5 + github.com/gorilla/websocket v1.4.1 ) go 1.13 diff --git a/private.go b/private.go index fabac42f754a69820536df064a247054fc0b17a2..eb5cf26a9d22b48f814912b132f0c96441d55d0b 100644 --- a/private.go +++ b/private.go @@ -47,11 +47,13 @@ func marshal(msg *SendMsg) ([]byte, error) { message.CmdData = msg.CmdData message.Status = msg.Status message.Msg = msg.Msg + message.CallbackMsg = msg.CallbackMsg message.Cmdkey = msg.Cmdkey message.Priority = msg.Priority message.PageKey = msg.PageKey message.Channel = msg.Channel message.PageId = msg.PageId + message.Desc = msg.Desc data, err := proto.Marshal(message) return data, err } @@ -77,6 +79,8 @@ func unMarshal(data []byte) (*SendMsg, error) { message.PageKey = msg.PageKey message.Channel = msg.Channel message.PageId = msg.PageId + message.Desc = msg.Desc + message.CallbackMsg = msg.CallbackMsg return message, err }