This commit is contained in:
lightings 2023-06-09 15:09:01 +08:00
parent ade2af028c
commit 0f34c40d1f
3 changed files with 18 additions and 9 deletions

View File

@ -28,10 +28,12 @@ var chatRoute = function(session, msg, app, cb) {
cb(new Error('can not find chat servers.')); cb(new Error('can not find chat servers.'));
return; return;
} }
var uid = session.get('uid');
var res = dispatcher.dispatch(session.get('uid'), chatServers); if (uid) {
var res = dispatcher.dispatch(uid, chatServers);
cb(null, res.id); cb(null, res.id);
}
}; };
// app configuration // app configuration

View File

@ -4,7 +4,8 @@ const { Message } = require("./Message");
const port = 4999; const port = 4999;
// const host = "192.168.100.173"; // const host = "192.168.100.173";
const host = "r2.cebggame.com"; const host = "62.234.46.11";
//const host = "r2.cebggame.com";
const stick = new Stick(1024); const stick = new Stick(1024);
stick.setMaxBodyLen(MaxBodyLen["32K"], true); stick.setMaxBodyLen(MaxBodyLen["32K"], true);
@ -110,8 +111,8 @@ beforeAll(() => {
serial: 123456, serial: 123456,
route: "gate.gateHandler.queryEntry", route: "gate.gateHandler.queryEntry",
params: { params: {
// uid: "6516_2006_0xef59f6cc4d190a0ae576c46d4583e92b61174340", uid: "6516_2006_0xef59f6cc4d190a0ae576c46d4583e92b61174340",
uid: "6516_2006_0xa5069f54f2ed021e0ac47dbb385420a0d5f41be3", // uid: "6516_2006_0xa5069f54f2ed021e0ac47dbb385420a0d5f41be3",
}, },
}; };
client.write(stick.makeData(Message.TYPE_REQUEST, JSON.stringify(param))); client.write(stick.makeData(Message.TYPE_REQUEST, JSON.stringify(param)));
@ -123,8 +124,8 @@ describe("client", () => {
let msg; let msg;
test("entry", async () => { test("entry", async () => {
// msg = await rpc("connector.entryHandler.entry", { uid: "6516_2006_0xef59f6cc4d190a0ae576c46d4583e92b61174340", }); msg = await rpc("connector.entryHandler.entry", { uid: "6516_2006_0xef59f6cc4d190a0ae576c46d4583e92b61174340", });
msg = await rpc("connector.entryHandler.entry", { uid: "6516_2006_0xa5069f54f2ed021e0ac47dbb385420a0d5f41be3", }); // msg = await rpc("connector.entryHandler.entry", { uid: "6516_2006_0xa5069f54f2ed021e0ac47dbb385420a0d5f41be3", });
console.log(msg); console.log(msg);
expect(msg.code).toBe(200); expect(msg.code).toBe(200);
}); });

View File

@ -161,8 +161,14 @@ class PomeloClient extends EventEmitter {
} }
processPackage(msg) { processPackage(msg) {
try {
this.handlers[msg.type](msg.body); this.handlers[msg.type](msg.body);
} }
catch (ex) {
console.log("processPackage msg: ", msg);
console.error("processPackage error: ", ex);
}
}
heartbeat(data) { heartbeat(data) {
if (!this.heartbeatInterval) { if (!this.heartbeatInterval) {