158 lines
3.0 KiB
JavaScript
158 lines
3.0 KiB
JavaScript
// game2006api-z1-test.xxx.xx
|
||
// game2006-z1-test.xxx.xx
|
||
// game2006-z1-test-1.xxx.xx
|
||
|
||
// -z1-test.cebg.games:usa
|
||
// -z2-test.cebg.gamesjp
|
||
// -z3-test.cebg.games:sg
|
||
// -z4-test.cebg.games:tk
|
||
|
||
// game2006-z1-test-n1.cebg.games
|
||
// https://game2006ap-test.kingsome.cn
|
||
export var allBaseNet = {
|
||
usa: '-z1-test.cebg.games',
|
||
japan: '-z2-test.cebg.games',
|
||
singapore: '-z3-test.cebg.games',
|
||
turkey: '-z4-test.cebg.games',
|
||
};
|
||
|
||
const netIdHash = (function () {
|
||
const result = {};
|
||
for (let key in allBaseNet) {
|
||
const url = allBaseNet[key];
|
||
const zid = extractZid(url);
|
||
result[zid] = {
|
||
name: key,
|
||
url: url,
|
||
};
|
||
}
|
||
return result;
|
||
})();
|
||
|
||
const functionNet = {
|
||
login: 'https://login', //
|
||
service: 'https://service', //
|
||
gamelog: 'https://gamelog', //
|
||
cloud: 'https://cloud', //
|
||
gamemail: 'https://gamemail',
|
||
notify: 'https://notify',
|
||
stat: 'https://stat', //
|
||
relation: 'wss://relation', //
|
||
//game
|
||
gameapi: 'https://game2006api',
|
||
game: 'wss://game2006',
|
||
};
|
||
|
||
function getCommonParam() {
|
||
let os = '';
|
||
if (cc.sys.os == cc.sys.OS_ANDROID) {
|
||
os = 'android';
|
||
} else if (cc.sys.os == cc.sys.OS_IOS) {
|
||
os = 'ios';
|
||
} else {
|
||
os = cc.sys.os;
|
||
}
|
||
return (
|
||
'_net=' +
|
||
encodeURIComponent(localStorage.getItem('currentNet')) +
|
||
'&_os=' +
|
||
encodeURIComponent(os)
|
||
);
|
||
}
|
||
|
||
export function getNormalApiUrl(name) {
|
||
return (
|
||
functionNet[name] +
|
||
'-z3-test.cebg.games' +
|
||
'/webapp/index.php?' +
|
||
getCommonParam()
|
||
);
|
||
}
|
||
|
||
export function getExaminingUrl() {
|
||
return (
|
||
functionNet['login'] +
|
||
'-z3-test.cebg.games' +
|
||
'/webapp/index.php?' +
|
||
getCommonParam()
|
||
);
|
||
}
|
||
|
||
export function getRelationUrl() {
|
||
return (
|
||
functionNet['relation'] + '-z3-test.cebg.games' + '/friend/websocket'
|
||
);
|
||
}
|
||
|
||
export function getNodeUrl() {
|
||
return (
|
||
functionNet['game'].replace('wss://', 'https://') +
|
||
localStorage.getItem('currentNet') +
|
||
'/webapp/index.php?' +
|
||
getCommonParam()
|
||
);
|
||
}
|
||
|
||
export function extractZid(url) {
|
||
return Number(url[2]);
|
||
}
|
||
|
||
export function getZViewName(zid) {
|
||
switch (zid) {
|
||
case 1:
|
||
{
|
||
return 'USA';
|
||
}
|
||
break;
|
||
case 2:
|
||
{
|
||
return 'Japan';
|
||
}
|
||
break;
|
||
case 3:
|
||
{
|
||
return 'Singapore';
|
||
}
|
||
break;
|
||
case 4:
|
||
{
|
||
return 'Turkey';
|
||
}
|
||
break;
|
||
default:
|
||
{
|
||
return '';
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
|
||
export function getCurrentZid() {
|
||
try {
|
||
return extractZid(localStorage.getItem('currentNet'));
|
||
} catch (err) {
|
||
return 0;
|
||
}
|
||
}
|
||
|
||
function getZUrl(zid) {
|
||
return netIdHash[zid]['url'];
|
||
}
|
||
|
||
function getZName(zid) {
|
||
return netIdHash[zid]['name'];
|
||
}
|
||
|
||
export function getGameServer(teamUuid) {
|
||
const nodeId = teamUuid ? teamUuid.split('_')[0] : cc.SDKManage.NodeId;
|
||
const zid = teamUuid
|
||
? teamUuid.split('_')[1]
|
||
: extractZid(localStorage.getItem('currentNet'));
|
||
let urls = teamUuid ? getZUrl(zid) : localStorage.getItem('currentNet');
|
||
urls = urls.split('.');
|
||
urls[0] += '-n' + nodeId;
|
||
return functionNet['game'] + urls.join('.') + '/websocket';
|
||
}
|
||
|
||
// game2006 -z1-test-n1 .cebg.games
|