forked from zhangshiqian1214/skynet-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.update skynet submodule 2.update gateserver 3.fix shared_memory
- Loading branch information
Showing
41 changed files
with
1,135 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
---------------------------public----------------------- | ||
include("config_public") | ||
--------------------------------------------------------- | ||
|
||
start = "main" | ||
logfile = "db.log" | ||
debugPort = 7001 | ||
luaservice = luaservice .. "./service/dbserver/?.lua;" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
-- | ||
-- Author: Kuzhu1990 | ||
-- Date: 2013-12-16 18:52:11 | ||
-- Date: 2017-12-16 18:52:11 | ||
-- 有序的玩家类 | ||
-- | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--[[ | ||
连接名, mysql连接id, redis连接id, service服务名, 连接个数, 注释 | ||
svc_name, mysql_id, redis_id, service_name, svc_count, desc | ||
]] | ||
local db_config = { | ||
["unique_db"] = { | ||
svc_name = [[unique_db]], | ||
mysql_id = 1, | ||
redis_id = 1, | ||
service_name = ".unique_db", | ||
svc_count = 1, | ||
desc = [[该db用于惟一id, 玩家在线状态]], | ||
}, | ||
["account_db"] = { | ||
svc_name = [[account_db]], | ||
mysql_id = 1, | ||
redis_id = 0, | ||
service_name = ".account_db", | ||
svc_count = 4, | ||
desc = [[该db用于登陆(查询tb_account, tb_player)]], | ||
}, | ||
["lobby_db"] = { | ||
svc_name = [[lobby_db]], | ||
mysql_id = 1, | ||
redis_id = 2, | ||
service_name = ".lobby_db", | ||
svc_count = 1, | ||
desc = [[该db用于缓存玩家在线状态,玩家登录状态]], | ||
}, | ||
["game_db"] = { | ||
svc_name = [[game_db]], | ||
mysql_id = 1, | ||
redis_id = 3, | ||
service_name = ".game_db", | ||
svc_count = 1, | ||
desc = [[该db用于游戏房间注册等]], | ||
}, | ||
["agent_db"] = { | ||
svc_name = [[agent_db]], | ||
mysql_id = 1, | ||
redis_id = 4, | ||
service_name = ".agent_db", | ||
svc_count = 4, | ||
desc = [[该db用于缓存玩家数据(每个玩家id对应一个db)]], | ||
}, | ||
} | ||
return db_config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--[[ | ||
mysql连接id, mysql地址, mysql端口, mysql库名, mysql用户名, mysql密码, mysql包最大长度, 注释 | ||
mysql_id, mysql_host, mysql_port, mysql_database, mysql_user, mysql_password, mysql_max_packet_size, desc | ||
]] | ||
local mysql_config = { | ||
[1] = { | ||
mysql_id = 1, | ||
mysql_host = "127.0.0.1", | ||
mysql_port = 3306, | ||
mysql_database = "game", | ||
mysql_user = "game", | ||
mysql_password = "game!Zsq1214", | ||
mysql_max_packet_size = 1048576, | ||
desc = [[game库]], | ||
}, | ||
[2] = { | ||
mysql_id = 2, | ||
mysql_host = "127.0.0.1", | ||
mysql_port = 3306, | ||
mysql_database = "gamelog", | ||
mysql_user = "gamelog", | ||
mysql_password = "gamelog!Zsq1214", | ||
mysql_max_packet_size = 1048576, | ||
desc = [[gamelog库]], | ||
}, | ||
} | ||
return mysql_config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--[[ | ||
redis连接id, redis地址, redis端口, redis库名, redis验证, 注释 | ||
redis_id, redis_host, redis_port, redis_db, redis_auth, desc | ||
]] | ||
local redis_config = { | ||
[1] = { | ||
redis_id = 1, | ||
redis_host = "127.0.0.1", | ||
redis_port = 6379, | ||
redis_db = 0, | ||
redis_auth = nil, | ||
desc = [[全局数据缓存]], | ||
}, | ||
[2] = { | ||
redis_id = 2, | ||
redis_host = "127.0.0.1", | ||
redis_port = 6379, | ||
redis_db = 1, | ||
redis_auth = nil, | ||
desc = [[lobby数据缓存]], | ||
}, | ||
[3] = { | ||
redis_id = 3, | ||
redis_host = "127.0.0.1", | ||
redis_port = 6379, | ||
redis_db = 2, | ||
redis_auth = nil, | ||
desc = [[game数据缓存]], | ||
}, | ||
[4] = { | ||
redis_id = 4, | ||
redis_host = "127.0.0.1", | ||
redis_port = 6379, | ||
redis_db = 3, | ||
redis_auth = nil, | ||
desc = [[玩家数据缓存]], | ||
}, | ||
[5] = { | ||
redis_id = 5, | ||
redis_host = "127.0.0.1", | ||
redis_port = 6379, | ||
redis_db = 4, | ||
redis_auth = nil, | ||
desc = [[gamelog数据缓存]], | ||
}, | ||
} | ||
return redis_config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,98 @@ | ||
local skynet = require "skynet" | ||
|
||
local json = require "json" | ||
local proto_map = require "proto_map" | ||
local cluster_monitor = require "cluster_monitor" | ||
local context = require "context" | ||
local gate_mgr = require "gate.gate_mgr" | ||
local sproto_helper = require "sproto_helper" | ||
local client_msg = {} | ||
|
||
function client_msg.dispatch(fd, msg) | ||
local ok, msg = xpcall(function() | ||
|
||
end, debug.traceback) | ||
if not ok then | ||
function client_msg.get_context(c) | ||
local ctx = {} | ||
ctx.gate = cluster_monitor.get_current_nodename() | ||
ctx.watchdog = skynet.self() | ||
ctx.fd = c.fd | ||
ctx.ip = c.ip | ||
ctx.session = c.session | ||
return ctx | ||
end | ||
|
||
function client_msg.dispatch(c, header, msg) | ||
if not header or not header.protoid then | ||
return | ||
end | ||
|
||
local proto = proto_map.protos[header.protoid] | ||
if not proto then | ||
header.errorcode = SystemError.unknow_proto | ||
client_msg.send(c.fd, header) | ||
return | ||
end | ||
print("dispatch proto=", table.tostring(proto)) | ||
|
||
if proto.type ~= PROTO_TYPE.C2S then | ||
header.errorcode = SystemError.invalid_proto | ||
client_msg.send(c.fd, header) | ||
return | ||
end | ||
|
||
if proto.service and proto.service ~= SERVICE.AUTH and not c.auth_ok then | ||
header.errorcode = SystemError.no_auth_account | ||
client_msg.send(c.fd, header) | ||
return | ||
end | ||
|
||
if proto.server == SERVER.GAME and not header.roomproxy then | ||
header.errorcode = SystemError.unknow_roomproxy | ||
client_msg.send(c.fd, header) | ||
return | ||
end | ||
|
||
if not proto.service and not c.agentnode and not c.agentaddr then | ||
header.errorcode = SystemError.no_login_game | ||
client_msg.send(c.fd, header) | ||
return | ||
end | ||
|
||
local rpc_err | ||
local ctx = client_msg.get_context(c) | ||
|
||
--非游戏服务 | ||
if proto.service then | ||
if proto.service == SERVICE.ROOM then | ||
rpc_err = context.rpc_call(header.roomproxy, SERVICE.ROOM, "dispatch_client_request", ctx, msg) | ||
else | ||
local target_node = cluster_monitor.get_cluster_node_by_server(proto.server) | ||
if not target_node then | ||
header.errorcode = SystemError.service_maintance | ||
client_msg.send(c.fd, header) | ||
return | ||
end | ||
rpc_err = context.rpc_call(target_node.nodename, proto.service, "dispatch_client_request", ctx, msg) | ||
end | ||
|
||
else | ||
rpc_err = context.rpc_call(c.agentnode, c.agentaddr, "dispatch_client_request", ctx, msg) | ||
end | ||
|
||
if rpc_err ~= RPC_ERROR.OK then | ||
header.errorcode = SystemError.service_stoped | ||
client_msg.send(c.fd, header) | ||
return | ||
end | ||
end | ||
|
||
function client_msg.send(fd, ...) | ||
|
||
function client_msg.send(fd, header, data) | ||
if skynet.getenv("websocket_test") then | ||
local j_packet = json.encode({header = header, data = data}) | ||
skynet.send(gate_mgr.get_gate(), "lua", "send_buffer", fd, j_packet, true) | ||
return | ||
end | ||
|
||
local buffer = sproto_helper.pack(header, data) | ||
if buffer then | ||
skynet.send(gate_mgr.get_gate(), "lua", "send_buffer", fd, buffer) | ||
end | ||
end | ||
|
||
return client_msg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.