Skip to content

Commit

Permalink
fix android compile error
Browse files Browse the repository at this point in the history
  • Loading branch information
garryyan committed Jan 4, 2017
1 parent 012c2fb commit 08f41c0
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 18 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[![Release Version](https://img.shields.io/badge/release-1.1.3-red.svg)](https://github.com/Tencent/mars/releases)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/Tencent/mars/pulls)
[![WeChat Approved](https://img.shields.io/badge/Wechat_Approved-1.1.3-red.svg)](https://github.com/Tencent/mars/wiki)
[![WeChat Approved](https://img.shields.io/badge/Platform-iOS | OS X | Android -brightgreen.svg)](https://github.com/Tencent/mars/wiki)

(中文版本请参看[这里](#mars_cn))

Expand Down
23 changes: 17 additions & 6 deletions mars/libraries/mars_android_sdk/jni/longlink_packer.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
// Tencent is pleased to support the open source community by making Mars available.
// Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.

// Licensed under the MIT License (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at
// http://opensource.org/licenses/MIT

// Unless required by applicable law or agreed to in writing, software distributed under the License is
// distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions and
// limitations under the License.


/*
* longlink_packer.cc
Expand All @@ -17,11 +29,10 @@
#include "comm/socket/unix_socket.h"
#endif

static uint16_t sg_client_version = 0;
static uint32_t sg_client_version = 0;

#pragma pack(push, 1)
struct __STNetMsgXpHeader
{
struct __STNetMsgXpHeader {
uint32_t head_length;
uint32_t client_version;
uint32_t cmdid;
Expand All @@ -38,8 +49,7 @@ namespace stn {
}
}

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)
{
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) {
__STNetMsgXpHeader st = {0};
if (_packed_len < sizeof(__STNetMsgXpHeader)) {
_package_len = 0;
Expand Down Expand Up @@ -68,7 +78,6 @@ static int __unpack_test(const void* _packed, size_t _packed_len, uint32_t& _cmd
}

void longlink_pack(uint32_t _cmdid, uint32_t _seq, const void* _raw, size_t _raw_len, AutoBuffer& _packed) {

__STNetMsgXpHeader st = {0};
st.head_length = htonl(sizeof(__STNetMsgXpHeader));
st.client_version = htonl(sg_client_version);
Expand Down Expand Up @@ -106,3 +115,5 @@ uint32_t longlink_noop_resp_cmdid() {return NOOP_CMDID;}
uint32_t signal_keep_cmdid() {return SIGNALKEEP_CMDID;}
void longlink_noop_req_body(AutoBuffer& _body) {}
void longlink_noop_resp_body(AutoBuffer& _body) {}

bool longlink_complexconnect_need_verify() { return false; }
11 changes: 5 additions & 6 deletions mars/libraries/mars_android_sdk/jni/longlink_packer.cc.rewriteme
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
static uint32_t sg_client_version = 0;

#pragma pack(push, 1)
struct __STNetMsgXpHeader
{
struct __STNetMsgXpHeader {
uint32_t head_length;
uint32_t client_version;
uint32_t cmdid;
Expand All @@ -50,8 +49,7 @@ namespace stn {
}
}

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)
{
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) {
__STNetMsgXpHeader st = {0};
if (_packed_len < sizeof(__STNetMsgXpHeader)) {
_package_len = 0;
Expand Down Expand Up @@ -79,8 +77,7 @@ static int __unpack_test(const void* _packed, size_t _packed_len, uint32_t& _cmd
return LONGLINK_UNPACK_OK;
}

void longlink_pack(uint32_t _cmdid, uint32_t _seq, const void* _raw, size_t _raw_len, AutoBuffer& _packed)
{
void longlink_pack(uint32_t _cmdid, uint32_t _seq, const void* _raw, size_t _raw_len, AutoBuffer& _packed) {
__STNetMsgXpHeader st = {0};
st.head_length = htonl(sizeof(__STNetMsgXpHeader));
st.client_version = htonl(sg_client_version);
Expand Down Expand Up @@ -118,3 +115,5 @@ uint32_t longlink_noop_resp_cmdid() {return NOOP_CMDID;}
uint32_t signal_keep_cmdid() {return SIGNALKEEP_CMDID;}
void longlink_noop_req_body(AutoBuffer& _body) {}
void longlink_noop_resp_body(AutoBuffer& _body) {}

bool longlink_complexconnect_need_verify() { return false; }
2 changes: 2 additions & 0 deletions mars/libraries/mars_android_sdk/jni/longlink_packer.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,6 @@ uint32_t signal_keep_cmdid();
void longlink_noop_req_body(AutoBuffer& _body);
void longlink_noop_resp_body(AutoBuffer& _body);

bool longlink_complexconnect_need_verify();

#endif // STN_SRC_LONGLINKPACKER_H_
9 changes: 3 additions & 6 deletions mars/stn/proto/longlink_packer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
static uint32_t sg_client_version = 0;

#pragma pack(push, 1)
struct __STNetMsgXpHeader
{
struct __STNetMsgXpHeader {
uint32_t head_length;
uint32_t client_version;
uint32_t cmdid;
Expand All @@ -50,8 +49,7 @@ namespace stn {
}
}

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)
{
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) {
__STNetMsgXpHeader st = {0};
if (_packed_len < sizeof(__STNetMsgXpHeader)) {
_package_len = 0;
Expand Down Expand Up @@ -79,8 +77,7 @@ static int __unpack_test(const void* _packed, size_t _packed_len, uint32_t& _cmd
return LONGLINK_UNPACK_OK;
}

void longlink_pack(uint32_t _cmdid, uint32_t _seq, const void* _raw, size_t _raw_len, AutoBuffer& _packed)
{
void longlink_pack(uint32_t _cmdid, uint32_t _seq, const void* _raw, size_t _raw_len, AutoBuffer& _packed) {
__STNetMsgXpHeader st = {0};
st.head_length = htonl(sizeof(__STNetMsgXpHeader));
st.client_version = htonl(sg_client_version);
Expand Down

0 comments on commit 08f41c0

Please sign in to comment.