Skip to content

Commit

Permalink
compatible with proxying to processId. colyseus/colyseus#176
Browse files Browse the repository at this point in the history
  • Loading branch information
endel committed Mar 31, 2019
1 parent 34219d5 commit b853bbe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "colyseus.js",
"version": "0.10.3",
"version": "0.10.4",
"description": "Multiplayer Game Client for the Browser",
"keywords": [
"colyseus",
Expand All @@ -23,7 +23,7 @@
"prepublish": "tsc && npm run build",
"tslint": "tslint --project .",
"postinstall": "npm run -s donate",
"donate": "echo \"\u001b[35m\u001b[1mLove Colyseus? ⚔ Support its development by becoming a backer:\u001b[22m\u001b[39m ⚔ \n > \u001b[34mhttps://www.patreon.com/endel\u001b[39m\""
"donate": "echo \"\u001b[35m\u001b[1mLove Colyseus? ⚔ Support its development by becoming a backer\u001b[22m\u001b[39m ⚔ \n > \u001b[34mhttps://www.patreon.com/endel\u001b[39m\""
},
"files": [
"lib",
Expand Down
8 changes: 7 additions & 1 deletion src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export class Client {
} else if (code === Protocol.JOIN_REQUEST) {
const requestId = view.getUint8(1);
const room = this.connectingRooms[requestId];
let processPath: string = '';

if (!room) {
console.warn('colyseus.js: client left room before receiving session id.');
Expand All @@ -164,7 +165,12 @@ export class Client {
room.id = utf8Read(view, 2);
this.rooms[room.id] = room;

room.connect(this.buildEndpoint(room.id, room.options));
const nextIndex = 3 + room.id.length;
if (view.byteLength > nextIndex) {
processPath = utf8Read(view, nextIndex) + "/";
}

room.connect(this.buildEndpoint(processPath + room.id, room.options));
delete this.connectingRooms[requestId];

} else if (code === Protocol.JOIN_ERROR) {
Expand Down

0 comments on commit b853bbe

Please sign in to comment.