11// Tencent is pleased to support the open source community by making Mars available.
22// Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
33
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
55// compliance with the License. You may obtain a copy of the License at
66// http://opensource.org/licenses/MIT
77
3232static uint32_t sg_client_version = 0 ;
3333
3434#pragma pack(push, 1)
35- struct __STNetMsgXpHeader
36- {
35+ struct __STNetMsgXpHeader {
3736 uint32_t head_length;
3837 uint32_t client_version;
3938 uint32_t cmdid;
@@ -43,15 +42,14 @@ struct __STNetMsgXpHeader
4342#pragma pack(pop)
4443
4544namespace 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+ }
5150}
5251
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) {
5553 __STNetMsgXpHeader st = {0 };
5654 if (_packed_len < sizeof (__STNetMsgXpHeader)) {
5755 _package_len = 0 ;
@@ -66,28 +64,27 @@ static int __unpack_test(const void* _packed, size_t _packed_len, uint32_t& _cmd
6664 if (client_version != sg_client_version) {
6765 _package_len = 0 ;
6866 _body_len = 0 ;
69- return LONGLINK_UNPACK_FALSE;
67+ return LONGLINK_UNPACK_FALSE;
7068 }
7169 _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+
7674 if (_package_len > 1024 *1024 ) { return LONGLINK_UNPACK_FALSE; }
7775 if (_package_len > _packed_len) { return LONGLINK_UNPACK_CONTINUE; }
7876
7977 return LONGLINK_UNPACK_OK;
8078}
8179
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) {
8481 __STNetMsgXpHeader st = {0 };
8582 st.head_length = htonl (sizeof (__STNetMsgXpHeader));
8683 st.client_version = htonl (sg_client_version);
8784 st.cmdid = htonl (_cmdid);
8885 st.seq = htonl (_seq);
8986 st.body_length = htonl (_raw_len);
90-
87+
9188 _packed.AllocWrite (sizeof (__STNetMsgXpHeader) + _raw_len);
9289 _packed.Write (&st, sizeof (st));
9390
@@ -98,8 +95,8 @@ void longlink_pack(uint32_t _cmdid, uint32_t _seq, const void* _raw, size_t _raw
9895
9996
10097int 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);
103100
104101 if (LONGLINK_UNPACK_OK != ret) return ret;
105102
@@ -112,7 +109,11 @@ int longlink_unpack(const AutoBuffer& _packed, uint32_t& _cmdid, uint32_t& _seq,
112109 * nooping param
113110 */
114111#define NOOP_CMDID 6
112+ #define SIGNALKEEP_CMDID 243
115113uint32_t longlink_noop_cmdid () {return NOOP_CMDID;}
116114uint32_t longlink_noop_resp_cmdid () {return NOOP_CMDID;}
115+ uint32_t signal_keep_cmdid () {return SIGNALKEEP_CMDID;}
117116void longlink_noop_req_body (AutoBuffer& _body) {}
118117void longlink_noop_resp_body (AutoBuffer& _body) {}
118+
119+ bool longlink_complexconnect_need_verify () { return false ; }
0 commit comments