Skip to content

Commit 03ef3e4

Browse files
committed
fix(jsonrpc):1.13.5,解决收到未注删的notify会打印警告的问题
1 parent 17a7e18 commit 03ef3e4

File tree

4 files changed

+22
-31
lines changed

4 files changed

+22
-31
lines changed

modules/jsonrpc/inner_types.h

Lines changed: 0 additions & 19 deletions
This file was deleted.

modules/jsonrpc/rpc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include <tbox/util/uuid.h>
2626

2727
#include "proto.h"
28-
#include "inner_types.h"
2928

3029
namespace tbox {
3130
namespace jsonrpc {
@@ -237,7 +236,8 @@ void Rpc::onRecvRequestInt(int int_id, const std::string &method, const Json &js
237236
iter->second(int_id, js_params, response);
238237
}
239238
} else {
240-
respondError(int_id, ErrorCode::kMethodNotFound, "method not found");
239+
if (int_id != 0)
240+
respondError(int_id, ErrorCode::kMethodNotFound, "method not found");
241241
}
242242
}
243243

modules/jsonrpc/types.h

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,32 @@
2626
namespace tbox {
2727
namespace jsonrpc {
2828

29+
//! 错误码
30+
enum ErrorCode {
31+
kParseError = -32700, //!< 解析错误
32+
kInvalidRequest = -32600, //!< 不合法的请求
33+
kMethodNotFound = -32601, //!< 找不到方法
34+
kInvalidParams = -32602, //!< 参数不合法
35+
kInternalError = -32603, //!< 内部异常
36+
kRequestTimeout = -32000, //!< 请求超时
37+
};
38+
2939
//! id 类型:整数、字串
3040
enum class IdType {
31-
kNone,
32-
kInt,
33-
kString
41+
kNone,
42+
kInt, //!< 整数id
43+
kString //!< 字串uuid
3444
};
3545

3646
//! 回复
3747
struct Response {
38-
Json js_result; //! 结果
48+
Json js_result; //! 结果
3949

40-
//! 错误相关
41-
struct {
42-
int code = 0; //! 错误码
43-
std::string message; //! 错误描述
44-
} error;
50+
//! 错误相关
51+
struct {
52+
int code = 0; //! 错误码
53+
std::string message; //! 错误描述
54+
} error;
4555
};
4656

4757
}

version.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@
2121
# TBOX版本号
2222
TBOX_VERSION_MAJOR := 1
2323
TBOX_VERSION_MINOR := 13
24-
TBOX_VERSION_REVISION := 4
24+
TBOX_VERSION_REVISION := 5

0 commit comments

Comments
 (0)