当前位置: 首页 > 工具软件 > oregano > 使用案例 >

Oregano的多人xmlSocket服务器配置

宋洲
2023-12-01

今天测试了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");
 }
}

 类似资料: