From ced98af96aaca69db13d42d92cab38568aacf75c Mon Sep 17 00:00:00 2001 From: Endel Dreyer Date: Tue, 27 Dec 2016 19:26:40 +0100 Subject: [PATCH] remove example from main project. add link to examples repository. --- README.md | 5 ++ examples/index.html | 95 ----------------------------------- examples/rooms/battle_room.js | 28 ----------- examples/rooms/chat_room.js | 64 ----------------------- examples/server.js | 23 --------- 5 files changed, 5 insertions(+), 210 deletions(-) delete mode 100644 examples/index.html delete mode 100644 examples/rooms/battle_room.js delete mode 100644 examples/rooms/chat_room.js delete mode 100644 examples/server.js diff --git a/README.md b/README.md index 50ef0a9..8bd9a9b 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,11 @@ room.onLeave.add(function() { }); ``` +## Useful links + +- [Server documentation](https://github.com/gamestdio/colyseus/wiki) +- [Official examples](https://github.com/gamestdio/colyseus-examples) + ## License MIT diff --git a/examples/index.html b/examples/index.html deleted file mode 100644 index 79c546f..0000000 --- a/examples/index.html +++ /dev/null @@ -1,95 +0,0 @@ - - - - - - - -

colyseus

- Messages
- -
- - - ping: -
- -
- - - - - diff --git a/examples/rooms/battle_room.js b/examples/rooms/battle_room.js deleted file mode 100644 index 0970650..0000000 --- a/examples/rooms/battle_room.js +++ /dev/null @@ -1,28 +0,0 @@ -var Room = require('colyseus').Room - -class BattleRoom extends Room { - - constructor (options) { - super(options) - this.setState({}) - console.log("BattleRoom created!", options) - } - - requestJoin(options) { - return (options.invalid_param != 10) - } - - onJoin (client) { - if (this.clients.length == 4) { - this.lock() - console.log("BattleRoom is now locked!") - } - } - - dispose () { - console.log("Dispose BattleRoom") - } - -} - -module.exports = BattleRoom diff --git a/examples/rooms/chat_room.js b/examples/rooms/chat_room.js deleted file mode 100644 index 848aa19..0000000 --- a/examples/rooms/chat_room.js +++ /dev/null @@ -1,64 +0,0 @@ -var Room = require('colyseus').Room - -class ChatRoom extends Room { - - constructor (options) { - super(options) - - this.setPatchRate(1000 / 192); - - this.setState({ messages: [] }) - - // Call game simulation at 60fps (16.6ms) - this.setSimulationInterval( this.tick.bind(this), 1000 / 60 ) - - console.log("ChatRoom created!", options) - } - - onJoin (client) { - this.sendState(client) - console.log("ChatRoom:", client.id, "connected") - } - - onLeave (client) { - this.state.messages.push("Left!"); - // console.log("ChatRoom:", client.id, "disconnected") - } - - onMessage (client, data) { - if (data.message == "kick") { - this.clients.filter(c => c.id !== client.id).forEach(other => other.close()) - - } else { - this.state.messages.push(data.message) - this.broadcast("This is a ROOM_DATA message.") - } - - console.log("ChatRoom:", client.id, data) - } - - tick () { - // - // This is your 'game loop'. - // Inside function you'll have to run the simulation of your game. - // - // You should: - // - move entities - // - check for collisions - // - update the state - // - - // Uncomment this line to see the simulation running and clients receiving the patched state - // In this example, the server simply adds the elapsedTime every 2 messages it receives - if ( this.state.messages.length % 3 == 0 ) { - this.state.messages.push(`${ this.clock.elapsedTime }: even`) - } - } - - dispose () { - console.log("Dispose ChatRoom") - } - -} - -module.exports = ChatRoom diff --git a/examples/server.js b/examples/server.js deleted file mode 100644 index 94f8383..0000000 --- a/examples/server.js +++ /dev/null @@ -1,23 +0,0 @@ -const path = require('path'); -const colyseus = require('colyseus'); -const http = require('http'); -const express = require('express'); - -const port = process.env.PORT || 2657; -const app = express(); - -const ChatRoom = require('./rooms/chat_room'); -const BattleRoom = require('./rooms/battle_room'); - -const server = http.createServer(app); -const gameServer = new colyseus.Server({server: server}); - -gameServer.register('chat', ChatRoom); -gameServer.register('battle', BattleRoom); - -app.use(express.static(__dirname)); -app.use(express.static(path.join(__dirname, "..", "dist"))); - -server.listen(port); - -console.log(`Listening on http://localhost:${ port }`);