1 package net.sz.game.login.logins; net.sz.game.login.logins.iscript.ILoginScript; * 登录管理类 7 * <br> 8 * author 失足程序员<br> <br> 10 * mail 492794628@qq.com<br> 11 * phone 13882122019<br> LoginManager { LoginManager instance = new LoginManager(); LoginManager getInstance() { 19 return instance; 20 } ILoginScript loginScript; 23 24 }
View Code
在脚本里面加入
@Override public void _init() { //反向注册 LoginManager.getInstance().loginScript = this; }
直接通过实例对象引用而不再是脚本对象集合调用形式;
脚本登录区分,
100渠道登录
package net.sz.game.login.scripts.logins; import net.sz.framework.nio.http.NioHttpRequest; import net.sz.framework.szlog.SzLogger; import net.sz.game.login.logins.LoginManager; import net.sz.game.login.logins.iscript.ILoginScriptPlatform; /** * 100渠道登录 * <br> * author 失足程序员<br> * blog <br> * mail 492794628@qq.com<br> * phone 13882122019<br> LoginScript100 implements ILoginScriptPlatform { SzLogger log = SzLogger.getLogger(); //:7073/login?platform=100&channel=100&username=ROBOTsz111&password=1 //:7073/login?platform=100&channel=100&username=ROBOT111&password=1&version=1&mac64=jdjdjjd&os=ios&fr=0202125 @Override public boolean login(int platform, int channelId, NioHttpRequest request) { if (100 == platform) { String username = request.getParam("username"); String password = request.getParam("password"); LoginManager.getInstance().loginScript._login(username, password, platform, channelId, request); return true; } return false; } }
View Code
200渠道登录
package net.sz.game.login.scripts.logins; import net.sz.framework.nio.http.NioHttpRequest; import net.sz.framework.szlog.SzLogger; import net.sz.game.login.logins.LoginManager; import net.sz.game.login.logins.iscript.ILoginScriptPlatform; /** * 200渠道登录 * <br> * author 失足程序员<br> * blog <br> * mail 492794628@qq.com<br> * phone 13882122019<br> LoginScript200 implements ILoginScriptPlatform { SzLogger log = SzLogger.getLogger(); //:7073/login?platform=100&username=ROBOT111&userpwd=1 @Override public boolean login(int platform, int channelId, NioHttpRequest request) { if (200 == platform) { String username = request.getParam("username"); String password = request.getParam("password"); LoginManager.getInstance().loginScript._login(username, password, platform, channelId, request); return true; } return false; } }
View Code
这时模拟以后接取渠道不同处理形式,
比如ios,360,91,豌豆荚等(拒绝广告);
1 NettyHttpServer nioHttpServer = NettyPool.getInstance().addBindHttpServer("0.0.0.0", ServerHttpPort); 2 //如果需要加入的白名单 nioHttpServer.addHttpBind((url, request) -> { 5 6 ArrayList<IHttpAPIScript> evts = ScriptManager.getInstance().getBaseScriptEntry().getEvts(IHttpAPIScript.class); 7 for (int i = 0; i < evts.size(); i++) { 8 IHttpAPIScript get = evts.get(i); (get.checkUrl(url)) { get.run(url, request); 13 return; 14 } 15 } 16 17 }, 20, "*");
开启http监听状态;这里可能需要你阅读之前的文章了解底层库支持;