local adUrl = config.getAdShowUrl() .. g_game_version
print("adUrl: ", adUrl)
local imgHttpClient = CCHttpRequest:open(adUrl, kHttpGet)
imgHttpClient:sendWithHandler(function (res, hnd)
if res:getResponseCode() == 200 then
local cjson = require("cjson")
local json = cjson.decode(res:getResponseData())
print("isshow: ", json.isshow)
if json and json.isshow and json.isshow == 1 then
local dict = CCDictionary:create()
protocol:callOCFunctionWithName_oneParam_noBack("adShow",dict)
print("kldny鎵撳紑骞垮憡:","璋冪敤SDK鏂规硶adShow")
end
end
end)
end
--娉ㄩ攢
function loginOut( ... )
if(isPlatform() == false)then
return
end
protocol:loginOut()
end
--骞冲彴鐧婚檰鍥炶皟
function registerLoginScriptHandler(pFunc)
if(isPlatform() == false)then
return
end
protocol:registerLoginScriptHandler(pFunc)
registerLogoutScriptHandler()
end
--骞冲彴娉ㄩ攢鍥炶皟
function registerLogoutScriptHandler(pFunc)
if(isPlatform() == false)then
return
end
print("registerLogoutHandler")
protocol:registerScriptHandlers("logout",function( ... )
print(GetLocalizeStringBy("key_2382"))
logout()
end)
end
function showToolBar( ... )
if(isPlatform() == false)then
return
end
protocol:showToolBar()
end
function getUin( ... )
if(isPlatform() == false)then
return
end
return protocol:callStringFuncWithParam("getUin",nil)
end
local _unlockPay = "true"
-- 瑙g鍏呭€煎姛鑳?function fnLockPay( lock )
_unlockPay = lock
end
function pay(coins)
if(isPlatform() == false)then
return
end
-- if(isDebug() == true and getPlatformFlag() ~= "Android_91")then
-- require "script/ui/tip/AlertTip"
-- AlertTip.showAlert("debug妯″紡涓嶆敮鎸佸厖鍊?", nil)
-- end
-- --android灏佹祴涓嶅紑鏀惧厖鍊? -- if g_system_type ~= kBT_PLATFORM_IOS and _unlockPay == "false" then
-- require "script/ui/tip/AlertTip"
-- AlertTip.showAlert("灏佹祴鏈熼棿涓嶅紑鏀惧厖鍊?", nil)
-- return
-- end
local platformName = protocol:callStringFuncWithParam("getPlatformName",nil)
if(platformName == "Android_vivo")then
--璋冪敤骞冲彴鎺ㄩ€佹帴鍙o紝杩斿洖鍏呭€兼墍闇€鍙傛暟锛屽鏋滄湁鐢ㄥ埌锛岃閲嶆瀯
local requestCallback = function(res, hnd)
LoadingUI.reduceLoadingUI()
if(res:getResponseCode()~=200)then
require "script/ui/tip/AlertTip"
AlertTip.showAlert( "缃戠粶寮傚父锛岃绋嶅悗鍐嶈瘯", nil, false, nil)
return
end
local xml = require "script/utils/LuaXml"
local orderXmlString = res:getResponseData()
print("pushInterface Call:" .. orderXmlString)
local xmlTable = LuaXML.eval(orderXmlString)
--淇濆瓨鐧婚檰鏁版嵁
if(xmlTable == nil) then
-- AlertTip.showAlert("杩炴帴宸叉柇寮€锛岃閲嶆柊鐧诲綍锛?, loginAgain)
require "script/ui/tip/AlertTip"
AlertTip.showAlert("鍒涘缓澶辫触銆?, nil)
return
end
local param = config.getPayParam(coins)
param:setObject(CCString:create(xmlTable:find("vivoSignature")[1]),"vivoSignature")
param:setObject(CCString:create(xmlTable:find("vivoOrder")[1]),"vivoOrder")
protocol:pay(param)
end
local requestUrl
if(isDebug())then
requestUrl = config.getOrderUrl_debug(coins)
else
requestUrl = config.getOrderUrl(coins)
end
print("getOrderURL:",requestUrl)
require "script/ui/network/LoadingUI"
LoadingUI.addLoadingUI()
local httpClent = CCHttpRequest:open(requestUrl, kHttpGet)
httpClent:sendWithHandler(requestCallback)
else
local param = config.getPayParam(coins)
protocol:pay(param)
end
end
--鍒濆鍖栧钩鍙癝erver
function initPlGroup( ... )
local platformName = protocol:callStringFuncWithParam("getPlatformName",nil)
if (platformName == "Android_km" or platformName == "Android_ck") then
protocol:callOCFunctionWithName_oneParam_noBack("initServer",config.getGroupParam())
end
end
-- 瑙g鍏呭€煎姛鑳?function fnUnlockPay( ... )
_lockPay = false
end
function getSessionId()
if(isPlatform() == false)then
return
end
return protocol:callStringFuncWithParam("getSessionId",nil)
end
--鎺ユ敹娓告垙鍐呴儴鐜╁绛夌骇淇℃伅
function sendRoleLevelInfo(level)
local platformName = protocol:callStringFuncWithParam("getPlatformName",nil)
if(platformName == "ios_kimi") then
if (tonumber(level) == 5) then
local dict = CCDictionary:create()
dict:setObject(CCString:create(level),"level")
protocol:callOCFunctionWithName_oneParam_noBack("sendRoleLevelInfo",dict)
end
end
end
--鑾峰彇鏈嶅姟鍣ㄥ垪琛?function getServerList()
local platformName = getPlatformFlag()
if(platformName ~= "IOS_91" and platformName ~= "Android_91") then
login()
end
--閫氱煡SDK绋嬪簭杩涘叆閫夋湇涓婚〉闈? Platform.sendInformationToPlatform(kComeInMainLayer)
local httpClent = nil
require "script/ui/network/LoadingUI"
-- LoadingUI.addLoadingUI()
if(not isDebug())then
httpClent = CCHttpRequest:open(config.getServerListUrl(), kHttpGet)
print("url",config.getServerListUrl())
else
httpClent = CCHttpRequest:open(config.getServerListUrl_debug(), kHttpGet)
print("url",config.getServerListUrl_debug())
end
httpClent:sendWithHandler(function(res, hnd)
-- LoadingUI.reduceLoadingUI()
local function resultCallback(resultTable)
if(resultTable == nil) then
print("get serverlist failed!!")
require "script/ui/tip/AlertTip"
AlertTip.showAlert(GetLocalizeStringBy("key_2847"), function ( ... )
require "script/Platform"
Platform.quit()
end)
return
end
for i=1, #resultTable do
local v = resultTable[i]
if v.desc and v.open then
require "script/ui/login/LoginScene"
LoginScene.setNotice(v.open, v.desc)
resultTable[i] = nil
break
end
end
ServerList.serverListData = resultTable
LoginScene.createSelectServer()
end
--鍒ゆ柇http鐘舵€佹槸鍚﹀悎娉? if(res:getResponseCode() ~= 200) then
print("error responseCode :", res:getResponseCode())
require "script/ui/tip/AlertTip"
AlertTip.showAlert(GetLocalizeStringBy("key_2847"), function ( ... )
require "script/Platform"
Platform.quit()
end)
end
if(res:getResponseData() == "")then
require "script/ui/tip/AlertTip"
AlertTip.showAlert(GetLocalizeStringBy("key_3354"), function()
require "script/Platform"
Platform.quit()
end)
return
end
BTUtil:parseServerList(res:getResponseData(), resultCallback)
end)
end
--鐧婚檰鎴愬姛鍚庤幏鍙杙id
function getPidBySessionId( session_id )
-- if _pid then
-- LoginScene.loginLogicServer(_pid)
-- return
-- end
local loginUrl = nil
if(not isDebug())then
loginUrl = config.getPidUrl(session_id)
else
loginUrl = config.getPidUrl_debug(session_id)
end
print("loginUrl=",loginUrl)
local httpClent = CCHttpRequest:open(loginUrl, kHttpGet)
require "script/ui/network/LoadingUI"
LoadingUI.addLoadingUI()
httpClent:sendWithHandler(
if(res:getResponseCode()~=200)then
require "script/ui/tip/AlertTip"
AlertTip.showAlert( GetLocalizeStringBy("key_1810"), nil, false, nil)
return
end
local xml = require "script/utils/LuaXml"
print("res:getResponseData()=",res:getResponseData())
local xmlTable = LuaXML.eval(res:getResponseData())
--淇濆瓨鐧婚檰鏁版嵁
if(xmlTable == nil or xmlTable:find("uid") == nil) then
Platform.loginOut()
-- AlertTip.showAlert(GetLocalizeStringBy("key_1889"), loginAgain)
require "script/ui/tip/AlertTip"
AlertTip.showAlert(GetLocalizeStringBy("key_3194"), nil)
CCLuaLog("swap user info error -> uid is nill")
return
end
local uid = xmlTable:find("uid")[1]
local errornu = xmlTable:find("errornu")[1]
if(errornu == "0") then
_pid = uid
print("_pid=",_pid)
if(type(config.setLoginInfo) == "function")then
config.setLoginInfo(xmlTable)
end
if(_loginBackCall)then
print("_loginBackCall",_loginBackCall)
_loginBackCall()
_loginBackCall=nil
end
elseif(errornu == "3") then
require "script/ui/tip/AlertTip"
AlertTip.showAlert(GetLocalizeStringBy("key_1411"), nil)
CCLuaLog("swap user info error errornu is not 0")
return
else
-- SDK91Share:shareSDK91():loginOut()
require "script/ui/tip/AlertTip"
AlertTip.showAlert(GetLocalizeStringBy("key_1414"), nil)
CCLuaLog("swap user info error errornu is not 0")
return
end
end)
end
--缁熶竴鎺ユ敹娓告垙鍐呴儴浼犺繃鏉ョ殑娑堟伅--messageType鏄笂闈㈠畾涔夌殑鏂规硶绫诲瀷,param鏄檮鍔犲弬鏁?鍙紶闅忔剰鍙傛暟)
function sendInformationToPlatform(messageType, param)
if(isPlatform() == false)then
return
end
local platformName = protocol:callStringFuncWithParam("getPlatformName",nil)
local dict = CCDictionary:create()
if (messageType == kComeInMainLayer) then
dict:setObject(CCString:create(messageType),"type")
protocol:callOCFunctionWithName_oneParam_noBack("receiveInformationFromLua",dict)
return
end
--娌℃湁鏂规硶getPlatformName鐨勫钩鍙?缁撴潫璋冪敤,鎰忓懗鐫€涓嶉渶瑕?缁熻鐩稿叧鏁版嵁
if(type(config.getUserInfoParam) == "function")then
--鍒氳繘鍏ラ€昏緫鏈嶅姟鍣ㄧ殑鏃跺€?鏈夎幏鍙栦笉鍒扮殑鍙傛暟 鍥犳鍋氫笅鍖哄垎
if(messageType == kEnterGameServer)then
dict = config.getUserInfoParam(beforeGame)
else
dict = config.getUserInfoParam(inTheGame)
end
end
--鐩戝惉瑙掕壊鍗囩骇,娣诲姞绛夌骇鍙傛暟
if(messageType == kRoleLevelInfo)then
local level = param
dict:setObject(CCString:create(level),"level")
end
--娉ㄥ唽鍒嗕韩鍚庣殑鏂规硶鍥炶皟, 骞惰缃垎浜殑鍐呭
if(messageType == kShareButtonClick)then
print("registerShareCallback")
protocol:registerScriptHandlers("shareCallBack",function( param )
print(GetLocalizeStringBy("key_3190"),param.code)
require "script/ui/share/ShareLayer"
ShareLayer.shareCallback(param.code)
end)
if(platformName == "ios_kimi") then
local feed = GetLocalizeStringBy("key_1647")
local caption = "銆婃斁闁嬮偅涓夊湅銆嬫柊娲惧崱鐗岋紝璁撴垜鍏堜締锛?
local description = GetLocalizeStringBy("key_1851")
local link = "http://click.adzcore.com/1.0.b3e6280ce230d006cbd71de2dd2f2322c"
local picture = "http://static.kimi.com.tw/web/nsg/images/fb_nsg_icon.png"
dict:setObject(CCString:create(feed),"feed")
dict:setObject(CCString:create(caption),"caption")
dict:setObject(CCString:create(description),"description")
dict:setObject(CCString:create(link),"link")
dict:setObject(CCString:create(picture),"picture")
end
end
end
-----------------------------涓嶱latform_SDK鐨勪俊鎭氦浜?-----------------------createByBaoXu
--android 鐐瑰嚮back鎺ュ彛
function exitSDK( ... )
if(getPlatformName() == "Android_uc") then
protocol:callStringFuncWithParam("exitUCSDK",nil)
else
exit()
end
end
function release( ... )
-- body
end
function exit()
if(isPlatform() == false)then
return
end
protocol:registerScriptHandlers("luaQuit",quit)
protocol:callOCFunctionWithName_oneParam_noBack("exit",nil)
end
--鍚姩闃叉矇杩峰€掕鏃?local beginSchedule = false
local minute = 0
function antiAddictionSchedule( time )
if(antiAddictionSchedule == false) then
antiAddictionSchedule = true
CCDirector:sharedDirector():getScheduler():scheduleScriptFunc(antiAddictionSchedule, 60, false)
end
minute = minute + 1
if(minute >= 3*60)then
if((minute - 3*60)%15 == 0)then
antiAddictionQuery(3)
end
elseif(minute >= 5*60)then
if((minute - 3*60)%5 == 0)then
antiAddictionQuery(5)
end
end
end
--闃叉矇杩?--type绫诲瀷:灏忔椂,3鎴?
function antiAddictionQuery(type)
--鏆傛椂鍙湁360鏈? if not (platformName == "Android_360")then
return
end
if(isPlatform() == false)then
return
end
local param = config.getPayParam(0)
param:setObject(CCString:create(type),"type")
protocol:callOCFunctionWithName_oneParam_noBack("antiAddictionQuery",param)
end
-- 娉ㄩ攢骞冲彴鐢ㄦ埛
function logout( ... )
BTEventDispatcher:getInstance():addLuaHandler("failed", function ( ... )
local scene = CCDirector:sharedDirector():getRunningScene()
local node = CCNode:create()
scene:addChild(node)
node:runAction(CCSequence:createWithTwoActions(CCDelayTime:create(0.1), CCCallFunc:create(function ( ... )
LoginScene.enter()
end)))
end, false)
require "script/network/Network"
Network.rpc(function ( ... )
print("...........rpc................logout")
end, "user.closeMe", "user.closeMe", nil, true)
setPid(nil)
end
--android 鐐瑰嚮menu鎺ュ彛
function clickMenu( ... )
local platformName = protocol:callStringFuncWithParam("getPlatformName",nil)
if not (platformName == "Android_360" or platformName == "Android_dl" or platformName == "Android_xm")then
return
end
function doRevive( flag,hid)
if(flag==false)then
else
logout()
protocol:callOCFunctionWithName_oneParam_noBack("switchAccount",nil)
end
end
require "script/ui/tip/AlertTip"
AlertTip.showAlert( "鎮ㄨ鎵ц鍝釜鎿嶄綔", doRevive, false, hid,GetLocalizeStringBy("key_2204"))
end
--[[
add by lichenyang
@des: 寰楀埌褰撳墠骞冲彴鏍囪瘑
@ret: 杩斿洖GlobalVars 閲岄潰鐨勫父閲?]]
function getCurrentPlatform( ... )
if(isDebug() and isPlatform() == false) then
return kPlatform_debug
end
local platformName = protocol:callStringFuncWithParam("getPlatformName",nil)
if(platformName == "IOS_91")then
return kPlatform_91_ios
elseif(platformName == "IOS_PP")then
return kPlatform_pp
elseif(platformName == "IOS_TBT")then
return kPlatform_tbt
elseif(platformName == "ios_pps")then
return kPlatform_pps
elseif(platformName == "Android_360")then
return kPlatform_360
elseif(platformName == "Android_91")then
return kPlatform_91_android
elseif(platformName == "Android_uc") then
return kPlatform_uc
elseif(platformName == "Android_dl") then
return kPlatform_dangle
elseif(platformName == "Android_dk") then
return kPlatform_dk
elseif(platformName == "Android_wdj")then
return kPlatform_wandoujia
elseif(platformName == "Android_jf")then
return kPlatform_jifeng
elseif(platformName == "Android_kg")then
return kPlatform_kugou
elseif(platformName == "Android_pps")then
return kPlatform_pps
elseif(platformName == "Android_jinshan")then
return kPlatform_jinshan
elseif(platformName == "Android_37wan") then
return kPlatform_37wan
elseif(platformName == "Android_xm") then
return kPlatform_xiaomi
elseif(platformName == "Android_az") then
return kPlatform_anzhi
elseif(platformName == "IOS_APPSTORE") then
return kPlatform_AppStore
elseif(platformName == "IOS_PGY") then
return kPlatform_pingguoyuan
elseif(platformName == "IOS_DANGLE") then
return kPlatform_dangleios
elseif(platformName == "IOS_PP2") then
return kPlatform_pp2
elseif(platformName == "IOS_ITOOLS") then
return kPlatform_iTools
elseif(platformName == "IOS_KUAIYONG") then
return kPlatform_kuaiyong
elseif(platformName == "ios_kldny") then
return kPlatform_kldny
elseif(platformName == "Android_ck") then
return kPlatform_chukong
elseif(platformName == "Android_oppo") then
return kPlatform_oppo
elseif(platformName == "Android_pptv") then
return kPlatform_pptv
elseif(platformName == "Android_kuwo") then
return kPlatform_kuwo
elseif(platformName == "Android_huawei") then
return kPlatform_huawei
elseif(platformName == "Android_sogou") then
return kPlatform_sogou
elseif(platformName == "Android_youmi") then
return kPlatform_youmi
elseif(platformName == "Android_mumayi") then
return kPlatform_mumayi
elseif(platformName == "Android_yyh") then
return kPlatform_yingyonghui
elseif(platformName == "Android_xl") then
return kPlatform_xunlei
elseif(platformName == "Android_lenovo") then
return kPlatform_lenovo
elseif(platformName == "Android_vivo") then
return kPlatform_vivo
elseif(platformName == "Android_ck_dianxin") then
return kPlatform_chukong_dx
elseif(platformName == "Android_ck_liantong") then
return kPlatform_chukong_lt
elseif(platformName == "Android_ck_yidongMM") then
return kPlatform_chukong_ydm
elseif(platformName == "Android_ck_yidongGame") then
return kPlatform_chukong_ydg
elseif(platformName == "Android_3g") then
return kPlatform_3g
elseif(platformName == "Android_lenovoPush") then
return kPlatform_lenovoPush
elseif(platformName == "Android_chaohaowan") then
return kPlatform_chaohaowan
else
return kPlatform_91_ios
end
end
--[[
@des:寰楀埌鐢ㄦ埛pid
]]
function getPid( ... )
return _pid
-- return "d66d39b609e16384"
end
--[[
@des:璁剧疆pid
]]
function setPid( pidStr )
_pid = pidStr
end
local AppPurchaseDebugUrl = "http://192.168.1.38/phone/exchange?pl=appstore&os=ios&gn=sanguo"
local AppPurchaseRelaseUrl = "http://mapifknsg.zuiyouxi.com/phone/exchange?pl=appstore&os=ios&gn=sanguo"
--[[
@des:鏀粯鐩戝惉澶?]]
function addPurchaseListener( ... )
local orderId = CCUserDefault:sharedUserDefault():getStringForKey("purchase_orderId")
local serverInfo = ServerList.getSelectServerInfo()
--鏀粯澶辫触骞冲彴鏁版嵁澶勭悊
local failRequestCallback = function ( res,hnd )
if(res:getResponseCode()~=200)then
require "script/ui/tip/AlertTip"
AlertTip.showAlert( GetLocalizeStringBy("key_1810"), nil, false, nil)
return
end
removeWaiteLayer()
local loginJsonString = res:getResponseData()
print("purchase failedCall:" , loginJsonString)
local cjson = require "cjson"
local cancelInfo = cjson.decode(loginJsonString)
print_t(cancelInfo)
end
local newUrl = nil
require "script/ui/login/LoginScene"
local bIsLarger = LoginScene.fnVersionCmp(g_publish_version, "1.1.8")
if bIsLarger then
newUrl = addMd5ForVerifyUrl(requestUrl)
end
if newUrl == nil then
newUrl = requestUrl
end
local httpClent = CCHttpRequest:open(newUrl, kHttpGet)
httpClent:sendWithHandler(failRequestCallback)
print("requestUrl:", requestUrl)
end
BTApplePurchase:shareApplePurchse():regisertPurchaseHandle(function ( pruchaseType, data )
print(GetLocalizeStringBy("key_1764"))
if(pruchaseType == "successed") then
CCMessageBox( GetLocalizeStringBy("key_1377"), GetLocalizeStringBy("key_3301"))
removeWaiteLayer()
elseif(pruchaseType == "failed") then
CCMessageBox(GetLocalizeStringBy("key_1917"), GetLocalizeStringBy("key_3301"))
failedCall()
removeWaiteLayer()
elseif(pruchaseType == "purchaseCallback") then
local oldUrl = BTApplePurchase:shareApplePurchse():getVerifyUrl()
local newUrl = addMd5ForVerifyUrl(oldUrl)
BTApplePurchase:shareApplePurchse():setMd5VerifyUrl(newUrl)
end
print(pruchaseType, data)
end)
end
local function fnSortUrlParams(pUrl)
require "script/utils/LuaUtil"
local result = ""
local fullUrl = pUrl --.. "&BabeltimeSanguo"
print("fullUrl : ", fullUrl)
local aData01 = string.splitByChar(fullUrl, "?")
if #aData01 > 1 then
local params = ""
for i=2, #aData01 do
params = params .. aData01[i]
end
local aData02 = string.splitByChar(params, "&")
if #aData02 > 1 then
table.sort(aData02, function (p01, p02)
return p01 < p02
end)
end
result = table.concat(aData02, "")
end
print("寮€濮媋pp store 鏀粯")
BTApplePurchase:shareApplePurchse():buyProduct(iapInfo.productId)
else
print(GetLocalizeStringBy("key_2254"), createOrderInfo.status, GetLocalizeStringBy("key_3366"), createOrderInfo.msg)
end
end
local newUrl = nil
require "script/ui/login/LoginScene"
local bIsLarger = LoginScene.fnVersionCmp(g_publish_version, "1.1.8")
if bIsLarger then
newUrl = addMd5ForVerifyUrl(requestUrl)
end
if newUrl == nil then
newUrl = requestUrl
end
local httpClent = CCHttpRequest:open(newUrl, kHttpGet)
httpClent:sendWithHandler(createOrderCallback)
print("requestUrl:", requestUrl)
end
local waitLayer = nil
function showWaitLayer( ... )
require "script/utils/BaseUI"
waitLayer = BaseUI.createMaskLayer(-5000)
local runningScene = CCDirector:sharedDirector():getRunningScene()
runningScene:addChild(waitLayer,999999999,90901)
local loadingSprite = CCSprite:create("images/common/bg/connectbg.png")
loadingSprite:setAnchorPoint(ccp(0.5, 0.5))
loadingSprite:setPosition(ccp(runningScene:getContentSize().width/2 , runningScene:getContentSize().height/2))
loadingSprite:setScale(g_fScaleX)
waitLayer:addChild(loadingSprite)
-- 鍔ㄧ敾
local loadEffectSprite = CCLayerSprite:layerSpriteWithName(CCString:create("images/base/effect/load/load4"), -1,CCString:create(""));
loadEffectSprite:retain()
loadEffectSprite:setAnchorPoint(ccp(0.5, 0.5))
loadEffectSprite:setPosition(ccp(loadingSprite:getContentSize().width*0.45, loadingSprite:getContentSize().height*0.5))
loadEffectSprite:setScale(0.4)
loadingSprite:addChild(loadEffectSprite)
loadEffectSprite:release()
end
function removeWaiteLayer( ... )
if(waitLayer ~= nil) then
waitLayer:removeFromParentAndCleanup(true)
waitLayer=nil
end
end
function openUrl( url )
if(url == nil)then
return
end
print("url=",url)
if(g_system_type == kBT_PLATFORM_ANDROID )then
local dict = CCDictionary:create()
dict:setObject(CCString:create(url),"url")
protocol:callOCFunctionWithName_oneParam_noBack("openUrl",dict)
else
PlatformUtil:openUrl(url)
end
end
function registerCrashHandler( ... )
print("registerCrashHandler")
protocol:registerScriptHandlers("handleCrash",function( param )
print("handleCrash")
print("param",param)
-- local cjson = require "cjson"
-- local dict = cjson.decode(param)
local param = ""
local dumpPath=""
param = param .. "&pid=" .. (_pid or 0)
param = param .. "&env=lua"
param = param .. "&gn=sanguo"
param = param .. "&os="..getOS()
param = param .. "&pl="..getPlName()
local serverInfo = ServerList.getSelectServerInfo()
param = param .. "&server="..serverInfo.host .. ":" .. serverInfo.port
param = param .. "&server_group="..serverInfo.group
-- for k,v in pairs(dict) do
-- if(k == "functionName")then
-- else
-- print(k .. "=" .. v)
-- param = param .. "&" .. k .. "=" .. v
-- end
-- end
print("url=",url2)
local dict = CCDictionary:create()
dict:setObject(CCString:create(url2),"url")
protocol:callOCFunctionWithName_oneParam_noBack("sendToServer",dict)
end)
end
function tracebackex()
local ret = ""
local level = 3
ret = ret .. "stack traceback:\n"
while true do
--get stack info
local info = debug.getinfo(level, "Sln")
if not info then break end
if info.what == "C" then -- C function
ret = ret .. tostring(level) .. "\tC function\n"
else -- Lua function
ret = ret .. string.format("\t[%s]:%d in function `%s`\n", info.short_src, info.currentline, info.name or "")
end
--get local vars
local i = 1
while true do
local name, value = debug.getlocal(level, i)
if not name then break end
ret = ret .. "\t\t" .. name .. " =\t" .. tostringex(value, 3) .. "\n"
i = i + 1
end
level = level + 1
end
return ret
end
function tostringex(v, len)
if len == nil then len = 0 end
local pre = string.rep('\t', len)
local ret = ""
if type(v) == "table" then
if len > 5 then return "\t{ ... }" end
local t = ""
for k, v1 in pairs(v) do
t = t .. "\n\t" .. pre .. tostring(k) .. ":"
t = t .. tostringex(v1, len + 1)
end
if t == "" then
ret = ret .. pre .. "{ }\t(" .. tostring(v) .. ")"
else
if len > 0 then
ret = ret .. "\t(" .. tostring(v) .. ")\n"
end
ret = ret .. pre .. "{" .. t .. "\n" .. pre .. "}"
end
else
ret = ret .. pre .. tostring(v) .. "\t(" .. type(v) .. ")"
end
return ret
end
OS_IOS="ios"
OS_ANDROID="android"
function getOS( ... )
local OS = "ios"
if g_system_type == kBT_PLATFORM_ANDROID then
OS = "android"
end
return OS
end
function getGameName( ... )
return "sanguo"
end
function getUrlParam( ... )
return "&pl=" .. config.getFlag() .. "&gn=" .. getGameName() .. "&os=" .. getOS()
end
-- added by hechao
function quit( ... )
if g_system_type == kBT_PLATFORM_ANDROID then
local dict = CCDictionary:create()
protocol:callOCFunctionWithName_oneParam_noBack("quit",dict)
else
CCDirector:sharedDirector():endToLua()
os.exit()
end
BTUtil:exitNow()
end
function getOperatorsFlag( ... )
local platformName = protocol:callStringFuncWithParam("getPlatformName",nil)
if(platformName == "Android_ck")then
return protocol:callStringFuncWithParam("getOperatorsFlag",nil)
end