Skip to content

Commit 5b28728

Browse files
committed
coly 16 state bug
0 parents  commit 5b28728

16 files changed

+4153
-0
lines changed

Diff for: .env.development

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SAMPLE=development

Diff for: .env.production

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SAMPLE=production

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

Diff for: README.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Welcome to Colyseus!
2+
3+
This project has been created using [⚔️ `create-colyseus-app`](https://github.com/colyseus/create-colyseus-app/) - an npm init template for kick starting a Colyseus project in TypeScript.
4+
5+
[Documentation](http://docs.colyseus.io/)
6+
7+
## :crossed_swords: Usage
8+
9+
```
10+
npm start
11+
```
12+
13+
## Structure
14+
15+
- `index.ts`: main entry point, register an empty room handler and attach [`@colyseus/monitor`](https://github.com/colyseus/colyseus-monitor)
16+
- `src/rooms/MyRoom.ts`: an empty room handler for you to implement your logic
17+
- `src/rooms/schema/MyRoomState.ts`: an empty schema used on your room's state.
18+
- `loadtest/example.ts`: scriptable client for the loadtest tool (see `npm run loadtest`)
19+
- `package.json`:
20+
- `scripts`:
21+
- `npm start`: runs `ts-node-dev index.ts`
22+
- `npm test`: runs mocha test suite
23+
- `npm run loadtest`: runs the [`@colyseus/loadtest`](https://github.com/colyseus/colyseus-loadtest/) tool for testing the connection, using the `loadtest/example.ts` script.
24+
- `tsconfig.json`: TypeScript configuration file
25+
26+
27+
## License
28+
29+
MIT

Diff for: ecosystem.config.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const os = require('os');
2+
3+
/**
4+
* COLYSEUS CLOUD WARNING:
5+
* ----------------------
6+
* PLEASE DO NOT UPDATE THIS FILE MANUALLY AS IT MAY CAUSE DEPLOYMENT ISSUES
7+
*/
8+
9+
module.exports = {
10+
apps : [{
11+
name: "colyseus-app",
12+
script: 'build/index.js',
13+
time: true,
14+
watch: false,
15+
instances: os.cpus().length,
16+
exec_mode: 'fork',
17+
wait_ready: true,
18+
env_production: {
19+
NODE_ENV: 'production'
20+
}
21+
}],
22+
};
23+

Diff for: loadtest/example.ts

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { Client, Room } from "colyseus.js";
2+
import { cli, Options } from "@colyseus/loadtest";
3+
4+
export async function main(options: Options) {
5+
const client = new Client(options.endpoint);
6+
const room: Room = await client.joinOrCreate(options.roomName, {
7+
// your join options here...
8+
});
9+
10+
console.log("joined successfully!");
11+
12+
room.onMessage("message-type", (payload) => {
13+
// logic
14+
});
15+
16+
room.onStateChange((state) => {
17+
console.log("state change:", state);
18+
});
19+
20+
room.onLeave((code) => {
21+
console.log("left");
22+
});
23+
}
24+
25+
cli(main);

0 commit comments

Comments
 (0)