1
1
// Tencent is pleased to support the open source community by making Mars available.
2
2
// Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
3
3
4
- // Licensed under the MIT License (the "License"); you may not use this file except in
4
+ // Licensed under the MIT License (the "License"); you may not use this file except in
5
5
// compliance with the License. You may obtain a copy of the License at
6
6
// http://opensource.org/licenses/MIT
7
7
32
32
static uint32_t sg_client_version = 0 ;
33
33
34
34
#pragma pack(push, 1)
35
- struct __STNetMsgXpHeader
36
- {
35
+ struct __STNetMsgXpHeader {
37
36
uint32_t head_length;
38
37
uint32_t client_version;
39
38
uint32_t cmdid;
@@ -43,15 +42,14 @@ struct __STNetMsgXpHeader
43
42
#pragma pack(pop)
44
43
45
44
namespace mars {
46
- namespace stn {
47
- void SetClientVersion (uint32_t _client_version) {
48
- sg_client_version = _client_version;
49
- }
50
- }
45
+ namespace stn {
46
+ void SetClientVersion (uint32_t _client_version) {
47
+ sg_client_version = _client_version;
48
+ }
49
+ }
51
50
}
52
51
53
- static int __unpack_test (const void * _packed, size_t _packed_len, uint32_t & _cmdid, uint32_t & _seq, size_t & _package_len, size_t & _body_len)
54
- {
52
+ static int __unpack_test (const void * _packed, size_t _packed_len, uint32_t & _cmdid, uint32_t & _seq, size_t & _package_len, size_t & _body_len) {
55
53
__STNetMsgXpHeader st = {0 };
56
54
if (_packed_len < sizeof (__STNetMsgXpHeader)) {
57
55
_package_len = 0 ;
@@ -66,28 +64,27 @@ static int __unpack_test(const void* _packed, size_t _packed_len, uint32_t& _cmd
66
64
if (client_version != sg_client_version) {
67
65
_package_len = 0 ;
68
66
_body_len = 0 ;
69
- return LONGLINK_UNPACK_FALSE;
67
+ return LONGLINK_UNPACK_FALSE;
70
68
}
71
69
_cmdid = ntohl (st.cmdid );
72
- _seq = ntohl (st.seq );
73
- _body_len = ntohl (st.body_length );
74
- _package_len = head_len + _body_len;
75
-
70
+ _seq = ntohl (st.seq );
71
+ _body_len = ntohl (st.body_length );
72
+ _package_len = head_len + _body_len;
73
+
76
74
if (_package_len > 1024 *1024 ) { return LONGLINK_UNPACK_FALSE; }
77
75
if (_package_len > _packed_len) { return LONGLINK_UNPACK_CONTINUE; }
78
76
79
77
return LONGLINK_UNPACK_OK;
80
78
}
81
79
82
- void longlink_pack (uint32_t _cmdid, uint32_t _seq, const void * _raw, size_t _raw_len, AutoBuffer& _packed)
83
- {
80
+ void longlink_pack (uint32_t _cmdid, uint32_t _seq, const void * _raw, size_t _raw_len, AutoBuffer& _packed) {
84
81
__STNetMsgXpHeader st = {0 };
85
82
st.head_length = htonl (sizeof (__STNetMsgXpHeader));
86
83
st.client_version = htonl (sg_client_version);
87
84
st.cmdid = htonl (_cmdid);
88
85
st.seq = htonl (_seq);
89
86
st.body_length = htonl (_raw_len);
90
-
87
+
91
88
_packed.AllocWrite (sizeof (__STNetMsgXpHeader) + _raw_len);
92
89
_packed.Write (&st, sizeof (st));
93
90
@@ -98,8 +95,8 @@ void longlink_pack(uint32_t _cmdid, uint32_t _seq, const void* _raw, size_t _raw
98
95
99
96
100
97
int longlink_unpack (const AutoBuffer& _packed, uint32_t & _cmdid, uint32_t & _seq, size_t & _package_len, AutoBuffer& _body) {
101
- size_t body_len = 0 ;
102
- int ret = __unpack_test (_packed.Ptr (), _packed.Length (), _cmdid, _seq, _package_len, body_len);
98
+ size_t body_len = 0 ;
99
+ int ret = __unpack_test (_packed.Ptr (), _packed.Length (), _cmdid, _seq, _package_len, body_len);
103
100
104
101
if (LONGLINK_UNPACK_OK != ret) return ret;
105
102
@@ -112,7 +109,11 @@ int longlink_unpack(const AutoBuffer& _packed, uint32_t& _cmdid, uint32_t& _seq,
112
109
* nooping param
113
110
*/
114
111
#define NOOP_CMDID 6
112
+ #define SIGNALKEEP_CMDID 243
115
113
uint32_t longlink_noop_cmdid () {return NOOP_CMDID;}
116
114
uint32_t longlink_noop_resp_cmdid () {return NOOP_CMDID;}
115
+ uint32_t signal_keep_cmdid () {return SIGNALKEEP_CMDID;}
117
116
void longlink_noop_req_body (AutoBuffer& _body) {}
118
117
void longlink_noop_resp_body (AutoBuffer& _body) {}
118
+
119
+ bool longlink_complexconnect_need_verify () { return false ; }
0 commit comments