//RoomInfomationCollecion\83N\83\89\83X
module.exports = function()
{
+ var _this = this;
var config = require("./configure.js");
var MySQLPool = new require("./mysql_pool.js");
var pool = new MySQLPool({
for(var rno in collection)
{
item={};
- item.applyflag = !$rooms.Get(rno).IsVolatile();
+ item.applyflag = !_this.Get(rno).IsVolatile();
item.password = collection[rno].password;
if(item.password == null)
item.password = "";
collection[rno].owner = $system_name;
};
var $gc_interval_id = setInterval(function(){
- for(var rno in this.rom_list)
+ for(var rno in _this.rom_list)
collection[rno].GCRomList();
},$gc_time_interval);
GetRoomList();
//RoomInfomation\83N\83\89\83X
function RoomInfomation(pass,hiddenlogflag)
{
+ var _this = this;
this.password = pass;
this.rom_list = {};
this.authed_list = {};
this.hiddenlog = hiddenlogflag;
this.GetConfig = function(){
var roomconfig = {};
- if(this.IsVolatile() == false)
+ if(_this.IsVolatile() == false)
{
- if(this.IsFixedPassword())
+ if(_this.IsFixedPassword())
roomconfig.type = 2;
- else if(this.IsHiddenLogFromRom())
+ else if(_this.IsHiddenLogFromRom())
roomconfig.type = 3;
else
roomconfig.type = 1;
- roomconfig.IsOwned = !this.IsFirstAuth();
+ roomconfig.IsOwned = !_this.IsFirstAuth();
}else{
roomconfig.type = 0;
}
return roomconfig;
}
this.IsVolatile = function(){
- return this.owner == null &&
- this.password == null &&
- this.time == null &&
- this.hiddenlog == null;
+ return _this.owner == null &&
+ _this.password == null &&
+ _this.time == null &&
+ _this.hiddenlog == null;
}
this.GetRomCount = function(){
var count = 0;
- for(var key in this.rom_list)
+ for(var key in _this.rom_list)
count++;
return count;
};
this.AddRom = function(ip){
var date = new Date();
- this.rom_list[ip] = {time:date.getTime()};
+ _this.rom_list[ip] = {time:date.getTime()};
};
this.RemoveRom = function(ip){
- delete this.rom_list[ip];
+ delete _this.rom_list[ip];
};
this.Reset = function(owner){
var date = new Date();
var time = date.getTime();
- this.password = null;
- this.authed_list = {};
- this.owner = owner;
- this.time = time;
+ _this.password = null;
+ _this.authed_list = {};
+ _this.owner = owner;
+ _this.time = time;
};
this.IsFirstAuth = function(){
- return this.owner == null;
+ return _this.owner == null;
};
this.IsAuthed = function(name){
- return name == this.owner ||
- name in this.authed_list;
+ return name == _this.owner ||
+ name in _this.authed_list;
};
this.IsHiddenLogFromRom = function(){
- return this.hiddenlog;
+ return _this.hiddenlog;
};
this.IsFixedPassword = function(){
- return this.owner == $system_name;
+ return _this.owner == $system_name;
};
this.IsOwner = function(name){
- return this.owner == name;
+ return _this.owner == name;
};
this.IsTimeout = function(){
var date = new Date();
var current_time = date.getTime();
- return !this.IsFixedPassword() &&
- current_time - this.time >= $reset_password_diff;
+ return !_this.IsFixedPassword() &&
+ current_time - _this.time >= $reset_password_diff;
};
this.RemoveAuth = function(name)
{
- delete this.authed_list[name];
+ delete _this.authed_list[name];
};
this.Auth = function(name,password){
- if(this.password != password)
+ if(_this.password != password)
return false;
var date = new Date();
var time = date.getTime();
- this.time = time;
- this.authed_list[name] = "";
+ _this.time = time;
+ _this.authed_list[name] = "";
return true;
};
this.SetPassword = function(owner,password){
- if(owner == this.owner &&
- !this.IsFixedPassword() &&
- !this.IsHiddenLogFromRom())
+ if(owner == _this.owner &&
+ !_this.IsFixedPassword() &&
+ !_this.IsHiddenLogFromRom())
{
var date = new Date();
- this.time = date.getTime();
- this.password = password;
+ _this.time = date.getTime();
+ _this.password = password;
return true;
}
return false;
this.GCRomList = function(){
var date = new Date();
var current_time = date.getTime();
- for(var ip in this.rom_list)
+ for(var ip in _this.rom_list)
{
- if(current_time - this.rom_list[ip].time >= $gc_time_interval)
- delete this.rom_list[ip];
+ if(current_time - _this.rom_list[ip].time >= $gc_time_interval)
+ delete _this.rom_list[ip];
}
};
}