Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
ce39bf9af2 | ||
![]() |
c120fccab2 | ||
![]() |
649c3208a7 | ||
![]() |
fd9a2ba7eb | ||
![]() |
03a8c08040 | ||
![]() |
da3c6ee96e |
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include "framework/cpp/msgqueue.h"
|
#include "framework/cpp/msgqueue.h"
|
||||||
#include "framework/cpp/tglog.h"
|
#include "framework/cpp/tglog.h"
|
||||||
|
#include "framework/cpp/utils.h"
|
||||||
|
|
||||||
struct MsgNode
|
struct MsgNode
|
||||||
{
|
{
|
||||||
@ -483,7 +484,25 @@ bool App::IsSeparateChannel(int channel)
|
|||||||
void App::LoadSeparateChannelConfig()
|
void App::LoadSeparateChannelConfig()
|
||||||
{
|
{
|
||||||
std::string data;
|
std::string data;
|
||||||
a8::ReadStringFromFile("../config/separate_channels.csv", data);
|
std::string filename = "../config/separate_channels.csv";
|
||||||
|
if (!f8::IsOnlineEnv()) {
|
||||||
|
if (f8::IsTestEnv()) {
|
||||||
|
filename = a8::Format("/root/pub/%d/%d/conf_test/game%d/masterserver.test/separate_channels.csv",
|
||||||
|
{
|
||||||
|
GAME_ID,
|
||||||
|
App::Instance()->instance_id,
|
||||||
|
GAME_ID
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
filename = a8::Format("/root/pub/%d/%d/conf_test/game%d/masterserver.dev/separate_channels.csv",
|
||||||
|
{
|
||||||
|
GAME_ID,
|
||||||
|
App::Instance()->instance_id,
|
||||||
|
GAME_ID
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
a8::ReadStringFromFile(filename, data);
|
||||||
std::vector<std::string> strings;
|
std::vector<std::string> strings;
|
||||||
a8::Split(data, strings, ',');
|
a8::Split(data, strings, ',');
|
||||||
separate_channel_hash_.clear();
|
separate_channel_hash_.clear();
|
||||||
@ -493,9 +512,10 @@ void App::LoadSeparateChannelConfig()
|
|||||||
separate_channel_hash_.insert(channel);
|
separate_channel_hash_.insert(channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
a8::UdpLog::Instance()->Info("LoadSeparateChannelConfig channelids:%s",
|
a8::UdpLog::Instance()->Debug("LoadSeparateChannelConfig %s channelids:%s",
|
||||||
{
|
{
|
||||||
GetSeparateChannelConfigData()
|
filename,
|
||||||
|
GetSeparateChannelConfigData()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
/*
|
|
||||||
类似http的错误码设计
|
|
||||||
0:成功
|
|
||||||
<400: 客户端的错
|
|
||||||
>500: 服务器的错
|
|
||||||
*/
|
|
||||||
enum ErrorCode_e
|
|
||||||
{
|
|
||||||
ERRNO_OK = 0,
|
|
||||||
|
|
||||||
};
|
|
@ -26,18 +26,8 @@ void GSMgr::UnInit()
|
|||||||
|
|
||||||
void GSMgr::_SS_WSP_RequestTargetServer(f8::MsgHdr& hdr, const ss::SS_WSP_RequestTargetServer& msg)
|
void GSMgr::_SS_WSP_RequestTargetServer(f8::MsgHdr& hdr, const ss::SS_WSP_RequestTargetServer& msg)
|
||||||
{
|
{
|
||||||
int channel = f8::ExtractChannelIdFromAccountId(msg.account_id());
|
int target_channel = GetTargetChannel(msg);
|
||||||
if (!App::Instance()->IsSeparateChannel(channel)) {
|
|
||||||
channel = 0;
|
|
||||||
}
|
|
||||||
#if 1
|
|
||||||
int src_channel = f8::ExtractChannelIdFromAccountId(msg.account_id());
|
|
||||||
if (channel == 0 &&
|
|
||||||
src_channel == kTouTiaoChannelId &&
|
|
||||||
msg.proto_version() == 2019071502) {
|
|
||||||
channel = src_channel;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
ss::SS_MS_ResponseTargetServer respmsg;
|
ss::SS_MS_ResponseTargetServer respmsg;
|
||||||
respmsg.set_context_id(msg.context_id());
|
respmsg.set_context_id(msg.context_id());
|
||||||
if (msg.is_reconnect()) {
|
if (msg.is_reconnect()) {
|
||||||
@ -51,11 +41,11 @@ void GSMgr::_SS_WSP_RequestTargetServer(f8::MsgHdr& hdr, const ss::SS_WSP_Reques
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
GSNode* node = GetNodeByTeamId(msg.team_id());
|
GSNode* node = GetNodeByTeamId(msg.team_id());
|
||||||
if (node && node->channel == channel) {
|
if (node && node->channel == target_channel) {
|
||||||
respmsg.set_host(node->ip);
|
respmsg.set_host(node->ip);
|
||||||
respmsg.set_port(node->port);
|
respmsg.set_port(node->port);
|
||||||
} else {
|
} else {
|
||||||
node = AllocNode(channel);
|
node = AllocNode(target_channel);
|
||||||
if (node) {
|
if (node) {
|
||||||
respmsg.set_host(node->ip);
|
respmsg.set_host(node->ip);
|
||||||
respmsg.set_port(node->port);
|
respmsg.set_port(node->port);
|
||||||
@ -314,3 +304,19 @@ void GSMgr::OnChannelChange(GSNode* node)
|
|||||||
RemoveNodeFromSortedNodes(node);
|
RemoveNodeFromSortedNodes(node);
|
||||||
AddNodeToSortedNodes(node);
|
AddNodeToSortedNodes(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int GSMgr::GetTargetChannel(const ss::SS_WSP_RequestTargetServer& msg)
|
||||||
|
{
|
||||||
|
int channel = f8::ExtractChannelIdFromAccountId(msg.account_id());
|
||||||
|
if ((channel == 6000 || channel == 0) && !msg.url().empty()) {
|
||||||
|
std::vector<std::string> strings;
|
||||||
|
a8::Split(msg.url(), strings, '/');
|
||||||
|
if (strings.size() > 1) {
|
||||||
|
channel = a8::XValue(strings[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!App::Instance()->IsSeparateChannel(channel)) {
|
||||||
|
channel = 0;
|
||||||
|
}
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
@ -48,6 +48,7 @@ class GSMgr : public a8::Singleton<GSMgr>
|
|||||||
void RemoveNodeFromSortedNodes(GSNode* node);
|
void RemoveNodeFromSortedNodes(GSNode* node);
|
||||||
std::vector<GSNode*>* GetSortedNodesByChannel(int channel);
|
std::vector<GSNode*>* GetSortedNodesByChannel(int channel);
|
||||||
void OnChannelChange(GSNode* node);
|
void OnChannelChange(GSNode* node);
|
||||||
|
int GetTargetChannel(const ss::SS_WSP_RequestTargetServer& msg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
#include "constant.h"
|
#include "constant.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "error_code.h"
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
namespace google
|
namespace google
|
||||||
|
@ -22,6 +22,9 @@ message SS_WSP_RequestTargetServer
|
|||||||
optional string server_info = 4;
|
optional string server_info = 4;
|
||||||
optional int32 is_reconnect = 5;
|
optional int32 is_reconnect = 5;
|
||||||
optional int32 proto_version = 6; //协议版本号Constant_e.ProtoVersion
|
optional int32 proto_version = 6; //协议版本号Constant_e.ProtoVersion
|
||||||
|
optional string url = 7;
|
||||||
|
optional string query_str = 8;
|
||||||
|
optional string session_id = 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
message SS_MS_ResponseTargetServer
|
message SS_MS_ResponseTargetServer
|
||||||
|
Loading…
x
Reference in New Issue
Block a user