139 lines
4.1 KiB
ActionScript
139 lines
4.1 KiB
ActionScript
package net.pixvi.myr.net
|
||
{
|
||
import flash.system.Capabilities;
|
||
import net.pixvi.common.utils.Alert;
|
||
import net.pixvi.common.utils.mobi.MobiTools;
|
||
import net.pixvi.myr.center.Table;
|
||
import net.pixvi.myrane.MyrAne;
|
||
import net.pixvi.myrloader.center.MyrCenter;
|
||
import net.pixvi.pfw.utils.core.Singleton;
|
||
import net.pixvi.pfw.utils.json.Json;
|
||
|
||
public class NetSystem
|
||
{
|
||
|
||
public static const SYNCHRO_TIME:String = "getSysCurTime/execute";
|
||
|
||
public static const GET_NOTICE:String = "gameService/queryGameNotice";
|
||
|
||
public static const GET_CONFIG:String = "gameService/queryGameConfig";
|
||
|
||
public static const FIRST_OPEN:String = "userServerService/firstOpenGame";
|
||
|
||
private var onSynchroTimeComplete:Function;
|
||
|
||
private var onFirstOpenComplete:Function;
|
||
|
||
private var onGetNoticeComplete:Function;
|
||
|
||
private var onGetConfigComplete:Function;
|
||
|
||
public function NetSystem()
|
||
{
|
||
super();
|
||
}
|
||
|
||
public static function getIns() : NetSystem
|
||
{
|
||
return Singleton.getInstanceOrCreate(NetSystem) as NetSystem;
|
||
}
|
||
|
||
public function synchroTime(onComplete:Function) : void
|
||
{
|
||
onSynchroTimeComplete = onComplete;
|
||
NetCenter.getIns().send("getSysCurTime/execute",{},synchroTimeHandler);
|
||
}
|
||
|
||
private function synchroTimeHandler(re:Object) : void
|
||
{
|
||
if(onSynchroTimeComplete != null)
|
||
{
|
||
onSynchroTimeComplete(re.time / 1000);
|
||
onSynchroTimeComplete = null;
|
||
}
|
||
}
|
||
|
||
public function firstOpen(onComplete:Function = null) : void
|
||
{
|
||
var para:Object = null;
|
||
onFirstOpenComplete = onComplete;
|
||
para = {
|
||
"os":MobiTools.getProtable(),
|
||
"osType":MobiTools.getProtable(),
|
||
"phoneScreen":Capabilities.screenResolutionX + "*" + Capabilities.screenResolutionY,
|
||
"phoneFactory":MyrAne.getPhoneBrand(),
|
||
"phoneModel":MyrAne.getPhoneModel(),
|
||
"channel":MyrCenter.channel,
|
||
"isp":MyrAne.getIsp(),
|
||
"network":MyrAne.getNetwork(),
|
||
"deviceId":MyrAne.getDeviceId(),
|
||
"imei":MyrAne.getIMEI()
|
||
};
|
||
if(Table.tjchannel != null && Table.tjchannel.tjchannel != null)
|
||
{
|
||
para.tjChannel = Table.tjchannel.tjchannel;
|
||
}
|
||
NetCenter.getIns().send("userServerService/firstOpenGame",para,firstOpenHandler,true,null,NetCenter.SERVER_MODE_CENTER);
|
||
}
|
||
|
||
private function firstOpenHandler(re:Object) : void
|
||
{
|
||
if(onFirstOpenComplete != null)
|
||
{
|
||
onFirstOpenComplete();
|
||
onFirstOpenComplete = null;
|
||
}
|
||
}
|
||
|
||
public function getNotice(onComplete:Function) : void
|
||
{
|
||
onGetNoticeComplete = onComplete;
|
||
NetCenter.getIns().send("gameService/queryGameNotice",{},getNoticeHandler);
|
||
}
|
||
|
||
private function getNoticeHandler(re:Object) : void
|
||
{
|
||
var notice:Object = null;
|
||
try
|
||
{
|
||
notice = Json.decode(re.gameNotice);
|
||
}
|
||
catch(e:Error)
|
||
{
|
||
Alert.showMsg("Notice error!");
|
||
}
|
||
if(onGetNoticeComplete != null)
|
||
{
|
||
onGetNoticeComplete(notice);
|
||
onGetNoticeComplete = null;
|
||
}
|
||
}
|
||
|
||
public function getConfig(onComplete:Function) : void
|
||
{
|
||
onGetConfigComplete = onComplete;
|
||
NetCenter.getIns().send("gameService/queryGameConfig",{},getConfigHandler);
|
||
}
|
||
|
||
private function getConfigHandler(re:Object) : void
|
||
{
|
||
var config:Object = null;
|
||
try
|
||
{
|
||
config = Json.decode(re.config);
|
||
}
|
||
catch(e:Error)
|
||
{
|
||
Alert.showMsg("Notice Error![configJsonErr]");
|
||
}
|
||
Table.game_config = config;
|
||
if(onGetConfigComplete != null)
|
||
{
|
||
onGetConfigComplete();
|
||
onGetConfigComplete = null;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|