今天測試了oreganno服務器
(1)下載代碼和服務器執行文件
服務器方需要安裝mysql,需要修改根目錄下的config.xml
(2)例子文件的結構
首先例子中的目錄結構是
example_as 目錄
oregano_as目錄
example.fla flash場景文件
config.xml 配置文件
首先要配置config.xml文件
包括服務器地址 ,數據庫服務器名字
(3)example_as的登陸代碼
首先創建的單個實體
org.omus.session = new org.omus._Session();
org.omus.clazz = new org.omus._Class();
org.omus.log = new org.omus._Log(org.omus._Log.CLIENT_DEV);
創建session實體的時候,就創建了socket
org.omus._Session = function () {
this.initEventDispatcher();
this.initMessageHandler();
this.addHandler("encoding","handleEncoding");
this.addHandler("loginRequest","handleLoginRequest");
this.addHandler("login","handleConnect");
this.addHandler("register","handleConnect");
this.addHandler("logout","handleLogout");
this.addHandler("reconnect","handleReconnect");
this.addHandler("error","handleError");
this.reset();
this.pwdEncoder = null;
this.createSocket();
// <temporary>
this.recVer = 3;
}
在登陸頁面首先調用
org.omus._Session.prototype.init = function (vers,addr,login,recon) {
if (this.online) {
org.omus.iLog.error("clj-006","");
return;
}
var argCheck = [[vers,"string",true],[addr,"string",true],[login,"number",true],[recon,"number",false]];
if (!org.omus.clazz.checkArguments("org.omus.session.init",argCheck)) return;
this.reset();
this.versionID = vers;
this.address = addr;
this.loginPort = login;
this.reconnectPort = recon;
}
點了註冊按鈕,進入login.connect,然後調用
org.omus.session.register(username,password,"");
否則進入登陸函數
org.omus._Session.prototype.login = function (user,pwd) {
if (!org.omus.clazz.checkArguments("org.omus.session.login",[[user,"string",true],[pwd,"string",true]])) return;
this.cache = [user,pwd];
this.loginMode = "login";
this.connect(this.address,this.loginPort);
}
登陸函數調用連接函數
org.omus._Session.prototype.connect = function (addr,port)
{
if (this.online && this.loginMode != "reconnect") {
org.omus.iLog.warn("clj-007","");
return;
}
if (typeof(addr) != "string" || typeof(port) != "number") {
org.omus.iLog.warn("clj-065","");
return;
}
var ok = this.socket.connect(addr,port);
if (!ok) {
if (this.loginMode == "reconnect") this.connectionBroken();
else this.cancelConnect("ses-012");
}
}