8000 Monorepo: extracting modules away from the @colyseus/core by endel · Pull Request #419 · colyseus/colyseus · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Monorepo: extracting modules away from the @colyseus/core #419

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 75 commits into from
Jul 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
447166e
wip experimenting with uWebSockets.js
endel May 3, 2021
8a1373a
uws: fix parsing incoming messages
endel May 4, 2021
611977b
uws: fix getAvailableRooms request
endel May 5, 2021
0ed75b2
breaking up colyseus into smaller packages. kickstarting lerna/monore…
endel May 11, 2021
efff0cd
WIP extracting transports and drivers from @colyseus/core
endel May 12, 2021
c0ecaf3
rename drivers -> driver
endel May 12, 2021
25ea28f
fixes generating .d.ts files final builds
endel May 13, 2021
f2761e9
extract fossil-delta serializer into its own package
endel May 13, 2021
50cca98
wip: test suite
endel May 13, 2021
864adfa
remove transport-related options from ServerOptions
endel May 15, 2021
a3405ec
remove pingInterval/pingMaxRetries from uWebSockets transport.
endel May 19, 2021
86afd10
move tests to 'colyseus' bundle. fix ws-transport build.
endel May 19, 2021
9ee3257
remove unused dependencies from @colyseus/core module
endel May 19, 2021
b8be09e
extract RedisPresence into @colyseus/redis-presence
endel May 19, 2021
da8eafc
improve TransportOptions for uWebSocketsTransport
endel May 19, 2021
9d9ec83
make 'server' optional for Transport implementations
endel May 19, 2021
ac2b8f7
uWebSockets.js: use onAbort() during GET /matchmake
endel May 27, 2021
38ed7ed
uWebSockets.js: prevent dropping 2 connections during _forciblyCloseC…
endel Jun 1, 2021
c6db8a0
Merge branch 'master' into monorepo
endel Jun 10, 2021
8aae0f0
rename uws-transport to uwebsockets-transport
endel Jun 27, 2021
ca463a1
add @colyseus/arena package as part of the monorepo
endel Jun 27, 2021
a65a863
remove unused code
endel Jun 28, 2021
45fd4b9
@colyseus/arena: now exposes a getTransport() method
endel Jun 28, 2021
e7afe62
@colyseus/arena: support async/await on initialize callbacks
endel Jun 29, 2021
730ac79
@colyseus/arena: update example
endel Jun 29, 2021
038e279
add redis driver support
May 26, 2021
3077bac
matchmaking driver: rename quit() to shutdown() #412
endel Jun 29, 2021
6162da7
soft deprecate transport options
endel Jul 1, 2021
2c2be43
use version 0.14.17
endel Jul 2, 2021
35f12ee
update current package version
endel Jul 2, 2021
83b59b7
remove package-lock from core
endel Jul 2, 2021
dd78021
remove unused files. copy README and LICENSE files to package folders.
endel Jul 2, 2021
1d2d57f
update README. preparing for prerelease
endel Jul 2, 2021
0a1591b
v0.14.17-alpha.1
endel Jul 2, 2021
7c11e50
update version
endel Jul 2, 2021
ded39d8
preparing for publish
endel Jul 2, 2021
fc05206
preparing for publish
endel Jul 2, 2021
8e7a19f
configure all scoped packages as access=public
endel Jul 2, 2021
2e3adce
bump alpha version
endel Jul 2, 2021
821f1d5
update 'publish-alpha' script
endel Jul 2, 2021
ae9fd74
fix bundle published files
endel Jul 2, 2021
d4f2690
skip copying README + LICENSE for submodules
endel Jul 2, 2021
051c017
push version change when bumping version
endel Jul 2, 2021
190c40e
bump alpha version
endel Jul 2, 2021
616820c
fixes publishing @colyseus/arena files
endel Jul 2, 2021
f44a28d
set lerna version as 'independent'
endel Jul 2, 2021
de84ce1
Publish
endel Jul 2, 2021
55f0566
fix: @colyseus/arena warning when uwebsockets-express could not be en…
endel Jul 2, 2021
e9a3e5e
fix: @colyseus/arena app name icon
endel Jul 2, 2021
2ad09b1
fix: @colyseus/uwebsockets-transport remove express compatibility pac…
endel Jul 2, 2021
f87d731
add @colyseus/monitor to the monorepo. update CONTRIBUTING file
endel Jul 6, 2021
bf55f8b
fix: @colyseus/ws-transport fix 'server' option
endel Jul 6, 2021
411511d
fix: @colyseus/uwebsockets-transport support closing websocket with c…
endel Jul 6, 2021
15e2d75
rename driver folder names
endel Jul 6, 2021
bea5f8a
avoid deprecated assert APIs on tests
endel Jul 7, 2021
35026bd
add MatchMakerDriver#clear() for testing purposes
endel Jul 7, 2021
49ee336
add test scenario specifically for LocalDriver/RedisDriver/MongooseDr…
endel Jul 7, 2021
d35de85
wip: testing RedisDriver #412
endel Jul 7, 2021
a00dd06
make sure driver is cleared after each test. RedisDriver tests passin…
endel Jul 8, 2021
580d5ec
test local + redis by default
endel Jul 8, 2021
1f4ddd6
client.send() afterNextPatch tests passing. closes #416 #330
endel Jul 8, 2021
5217dc4
uWebSocketTransport: avoid error when connection is closed. fixes aft…
endel Jul 8, 2021
6d934b7
test for custom leave/close code
endel Jul 8, 2021
8ef139a
@colyseus/uwebsockets-transport: support for .readyState
endel Jul 8, 2021
76cc90e
@colyseus/uwebsockets-transport: minimal compatibility to retrieving …
endel Jul 8, 2021
6ce73f6
uWebSockets.js: fix simulating latency
endel Jul 9, 2021
6dab67f
bump version
endel Jul 9, 2021
294431c
@colyseus/monitor: fixes build path
endel Jul 12, 2021
980e012
bump alpha version
endel Jul 12, 2021
eef556a
bump alpha version
endel Jul 12, 2021
4b3de54
@colyseus/monitor: ensure to remove trailing slash from frontend api …
endel Jul 12, 2021
2dbb22e
bump version
endel Jul 12, 2021
320a032
bump alpha version
endel Jul 12, 2021
7d6d90d
bump version
endel Jul 12, 2021
74aaab6
bump 0.14.18
endel Jul 12, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 24 additions & 12 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,37 @@
## How to contribute to Colyseus
# How to contribute to Colyseus

#### **Did you find a bug?**
## Working on Colyseus source files

* **Do not open up a GitHub issue if the bug is a security vulnerability in Colyseus**, and instead send us an email at [endel@gamestd.io](mailto:endel@gamestd.io).
- Clone the repository: `git clone git@github.com:colyseus/colyseus.git`
- Install its dependencies: `npm install`
- To run the test suite: `npm test`

* **Ensure the bug was not already reported** by searching on GitHub under [Issues](https://github.com/gamestdio/colyseus/issues).
Observations:

* If you're unable to find an open issue addressing the problem, [open a new one](https://github.com/gamestdio/colyseus/issues/new). Be sure to include a **title and clear description**, as much relevant information as possible, and a **code sample** or an **executable test case** demonstrating the expected behavior that is not occurring.
- The Colyseus project has multiple packages. They are all under `packages/` folder.
- We use [Lerna](https://github.com/lerna/lerna) for managing the multiple packages.
- Packages that have a `"build"` script are not going to be built with `rollup` (e.g. @colyseus/monitor)

#### **Did you write a patch that fixes a bug?**
---

* Open a new GitHub pull request with the patch.
## **Reporting an issue**

* Ensure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable.
- **Do not open up a GitHub issue if the bug is a security vulnerability in Colyseus**, and instead send us an email at [endel@lucidsight.com](endel@lucidsight.com).
- **Ensure the issue was not already reported** by searching on GitHub under [Issues](https://github.com/colyseus/colyseus/issues).
- If you're unable to find an open issue addressing the problem, [open a new one](https://github.com/colyseus/colyseus/issues/new). Be sure to include a **title and clear description**, as much relevant information as possible, and a **code sample** or an **executable test case** demonstrating the expected behavior that is not occurring.

* Before submitting, make sure the tests are still passing, by running `npm test`.
## **Did you write a patch that fixes a bug?**

#### **Did you fix whitespace, format code, or make a purely cosmetic patch?**
- Open a new GitHub pull request with the patch.
- Ensure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable.
- Before submitting, make sure the tests are still passing, by running `npm test`.

## **Did you fix whitespace, format code, or make a purely cosmetic patch?**

Changes that are cosmetic in nature and do not add anything substantial to the stability, functionality, or testability of Colyseus will generally not be accepted.

#### **Do you have questions about the source code?**
## **Do you have questions about the source code?**

- Ask any question about how to use Colyseus on our [Discord Community](https://discord.gg/RY8rRS7).

* Ask any question about how to use Colyseus on our [Discord Server](https://discord.gg/RY8rRS7).
---
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ node_modules
yarn.lock
/lib
.DS_Store
build/

.nyc_output
coverage
esm
dump.rdb
3 changes: 2 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Copyright (c) 2015 Endel Dreyer
Copyright (c) 2021 Lucid Sight
Copyright (c) 2015-2021 Endel Dreyer

MIT License:

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ for any kind of project you can think of!
You're encouraged to take a look on [some games being developed with
it](https://discuss.colyseus.io/category/5/showcase) and make your own!

> ⭐️ Enjoying Colyseus? Show your support by starring the project on GitHub ⭐️

## What Colyseus provides to you:

- WebSocket-based communication
Expand Down
40 changes: 40 additions & 0 deletions bundles/colyseus/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "colyseus",
"version": "0.14.17",
"description": "Multiplayer Framework for Node.js.",
"input": "./src/index.ts",
"main": "./build/index.js",
"module": "./build/index.mjs",
"typings": "./build/index.d.ts",
"scripts": {
"test": "TS_NODE_PROJECT=../../tsconfig/tsconfig.test.json COLYSEUS_SEAT_RESERVATION_TIME=0.3 COLYSEUS_PRESENCE_SHORT_TIMEOUT=300 c8 mocha --require ts-node/register test/**Test.ts test/**/**Test.ts --exit --timeout 15000"
},
"author": "Endel Dreyer",
"license": "MIT",
"keywords": [
"colyseus",
"multiplayer",
"netcode",
"realtime",
"networking",
"websockets"
],
"files": [
"build"
],
"repository": {
"type": "git",
"url": "git://github.com/colyseus/colyseus.git"
},
"homepage": "https://colyseus.io/",
"engines": {
"node": ">= 12.x"
},
"dependencies": {
"@colyseus/core": "^0.14.17",
"@colyseus/mongoose-driver": "^0.14.17",
"@colyseus/redis-presence": "^0.14.17",
"@colyseus/ws-transport": "^0.14.17& 10000 quot;
},
"gitHead": "320a0325f01eff3cd7afa8fb2efa80077ebdbf4a"
}
13 changes: 13 additions & 0 deletions bundles/colyseus/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export * from "@colyseus/core";

//
// 0.14.x compatibility:
// each "presence", "transport", and "driver" implementation have been extracted from the core.
//
import { Server } from '@colyseus/core';
import { WebSocketTransport } from '@colyseus/ws-transport';
Server.prototype['getDefaultTransport'] = function(options: any) {
return new WebSocketTransport(options);
}
export { RedisPresence } from '@colyseus/redis-presence';
export { MongooseDriver } from '@colyseus/mongoose-driver';
62 changes: 62 additions & 0 deletions bundles/colyseus/test/DriverTest.ts
9D2C
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import assert from "assert";
import { generateId, IRoomListingData, MatchMakerDriver } from "../src";

import { DRIVERS } from "./utils";

describe("Driver implementations", () => {
for (let i = 0; i < DRIVERS.length; i++) {
let driver: MatchMakerDriver;

describe(`Driver:${DRIVERS[i].name}`, () => {
beforeEach(async () => {
driver = new DRIVERS[i]();
await driver.clear();
});

afterEach(async () => {
await driver.shutdown();
});

async function createAndSave(data: Partial<IRoomListingData>) {
const cache = driver.createInstance(data);
await cache.save();
return cache;
}

it("createInstance, save, find", async () => {
const cache = await createAndSave({ roomId: generateId(), name: "one", locked: false, clients: 0, maxClients: 2 });
assert.strictEqual(0, cache.clients);
assert.strictEqual(false, cache.locked);
assert.strictEqual(2, cache.maxClients);

const entries = await driver.find({ name: "one" });
const cachedEntry = entries[0];
assert.strictEqual(1, entries.length);
assert.strictEqual(0, cachedEntry.clients);
assert.strictEqual(false, cachedEntry.locked);
assert.strictEqual(2, cachedEntry.maxClients);
});

it("find / findOne", async () => {
await createAndSave({ roomId: generateId(), name: "one", locked: false, clients: 1, maxClients: 2, });
await createAndSave({ roomId: generateId(), name: "one", locked: true, clients: 2, maxClients: 2, });
await createAndSave({ roomId: generateId(), name: "one", locked: false, clients: 3, maxClients: 4, });
const lastEntry = await createAndSave({ roomId: generateId(), name: "one", locked: true, clients: 4, maxClients: 4, });

const entries = await driver.find({});
assert.strictEqual(4, entries.length);

lastEntry.clients = 3;
lastEntry.locked = false;
lastEntry.name = "hello";
await lastEntry.save();

const lastEntryCached = await driver.findOne({ name: "hello" })
assert.strictEqual("hello", lastEntryCached.name);
assert.strictEqual(3, lastEntryCached.clients);
assert.strictEqual(false, lastEntryCached.locked);
});

});
}
});
4 changes: 2 additions & 2 deletions test/IPCTest.ts → bundles/colyseus/test/IPCTest.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import assert from "assert";

import { PRESENCE_IMPLEMENTATIONS } from "./utils";
import { subscribeIPC, requestFromIPC } from "../src/IPC";
import { subscribeIPC, requestFromIPC } from "@colyseus/core/build/IPC";

describe("Inter-process Communication", () => {
for (let i = 0; i < PRESENCE_IMPLEMENTATIONS.length; i++) {
const presence = PRESENCE_IMPLEMENTATIONS[i];
const presence = new PRESENCE_IMPLEMENTATIONS[i]();

describe(`Using presence: ${presence.constructor.name}`, () => {

Expand Down
Loading
0