目录结构调整
This commit is contained in:
81
codes/games/server/youle/server_room/class.tcplist.js
Normal file
81
codes/games/server/youle/server_room/class.tcplist.js
Normal file
@@ -0,0 +1,81 @@
|
||||
///////////////////////////////////////////////////
|
||||
//////////////cls_youle_room_tcplist: tcp连接列表类///////////
|
||||
///////////////////////////////////////////////////
|
||||
var cls_youle_room_tcplist = cls_youle_room_tcplist || {
|
||||
new: function() {
|
||||
var tcplist = {};
|
||||
tcplist.list = [];
|
||||
|
||||
//方法
|
||||
tcplist.method = {};
|
||||
|
||||
//载入tcp连接
|
||||
tcplist.method.load_tcp = function(str_tcpid, o_player){
|
||||
return cls_youle_room_tcplist.load_tcp(tcplist, str_tcpid, o_player);
|
||||
}
|
||||
|
||||
//查找tcp连接
|
||||
tcplist.method.find_tcp = function(str_tcpid){
|
||||
return cls_youle_room_tcplist.find_tcp(tcplist, str_tcpid);
|
||||
}
|
||||
|
||||
//删除tcp连接
|
||||
tcplist.method.delete_tcp = function(str_tcpid){
|
||||
return cls_youle_room_tcplist.delete_tcp(tcplist, str_tcpid);
|
||||
}
|
||||
|
||||
return tcplist;
|
||||
},
|
||||
|
||||
//载入tcp连接
|
||||
load_tcp: function(o_tcplsit, str_tcpid, o_player){
|
||||
var idx = cls_youle_room_tcplist.aryidx(str_tcpid);
|
||||
if (idx == -1){
|
||||
return null;
|
||||
}
|
||||
if (o_tcplsit.list.length <= idx){
|
||||
o_tcplsit.list.length = idx + 1;
|
||||
}
|
||||
var new_tcp = {};
|
||||
new_tcp.tcpid = str_tcpid;
|
||||
new_tcp.o_player = o_player;
|
||||
o_tcplsit.list[idx] = new_tcp;
|
||||
return new_tcp;
|
||||
},
|
||||
|
||||
//查找tcp连接
|
||||
find_tcp: function(o_tcplsit, str_tcpid){
|
||||
var idx = cls_youle_room_tcplist.aryidx(str_tcpid);
|
||||
if (idx == -1){
|
||||
return null;
|
||||
}
|
||||
if (o_tcplsit.list.length <= idx){
|
||||
return null;
|
||||
}
|
||||
return o_tcplsit.list[idx];
|
||||
},
|
||||
|
||||
//删除tcp连接
|
||||
delete_tcp: function(o_tcplsit, str_tcpid){
|
||||
var idx = cls_youle_room_tcplist.aryidx(str_tcpid);
|
||||
if (idx == -1){
|
||||
return;
|
||||
}
|
||||
if (o_tcplsit.list.length <= idx){
|
||||
return;
|
||||
}
|
||||
o_tcplsit.list[idx] = null;
|
||||
},
|
||||
|
||||
//计算tcp连接的数组下标
|
||||
aryidx: function(str_tcpid){
|
||||
var idx = parseInt(str_tcpid.replace("tcp_", ""));
|
||||
if (isNaN(idx)){
|
||||
return -1;
|
||||
}
|
||||
return idx - 10000;
|
||||
}
|
||||
}
|
||||
|
||||
//tcp连接列表
|
||||
youle_room.tcps = cls_youle_room_tcplist.new();
|
||||
Reference in New Issue
Block a user