incompl / cloak Goto Github PK
View Code? Open in Web Editor NEWA network layer for HTML5 games using Node.js
Home Page: http://incompl.github.io/cloak/
License: MIT License
A network layer for HTML5 games using Node.js
Home Page: http://incompl.github.io/cloak/
License: MIT License
room created and deleted events,
getroommembers,
pruneemptyrooms,
update to deleteuser
Subtask of #16
The player should be kicked back to the lobby, showing a message and a confirmation button labeled "Return to Lobby" when:
Looked into this a little -- if you run Crafty.stop(true)
then Crafty.init(blah blah blah)
then Crafty.components()
it returns only the base Crafty components. It seems like custom components need to be reloaded? @incompl interested in your take on this
room.age
room.messageMembers
Remove socket.io connect
and disconnect
handlers, or at least, make it clear what they are useful for. What do they do that begin
, resume
, and end
do not?
Add a connecting
and/or reconnecting
event handler.
this means tests could theoretically affect each other
already documented here: https://github.com/bocoup/cloak/wiki/ServerConfiguration
If I immediately emit a message after calling cloak.run() in the client
the message is not received in the server.
I don't consider this a critical-path task to finishing Grow21, but it is a cheating risk to have the server trust the client to self-report its scores.
This would be a pretty big refactor; I'd have to move a whole bunch of the game logic from the client to the server :/
I already did this, just filing a ticket so I remember to check it in from my other computer
Comes down to the room.members.length < room.size check in server index.js. If the roomsize isn't configured, room.size will equal null.
In https://github.com/incompl/cloak/wiki/GettingStarted
in this part, when I copy and paste this
{
name: 'My Cool Game'
}
and then run: npm install cloak --save
npm ERR! Failed to parse json
npm ERR! Unexpected token }
npm ERR! File: C:\Users\User\Documents\GitHub\multiplayer\package.json
npm ERR! Failed to parse package.json data.
npm ERR! package.json must be actual JSON, not just JavaScript.
npm ERR!
npm ERR! This is not a bug in npm.
npm ERR! Tell the package author to fix their package.json file. JSON.parse
I had to change with
{
"name": "MyCoolGame"
}
there are some links broken like:
this breaks resume functionality
specifically, don't do this: delete users[uid];
There is still a bit of work to hook up getting and setting of a users current rooms state or data (The latest test I added may be the quickest way and requires defining a getter and setter on the server config I think we should give for free). What are your thoughts on exposing methods that abstract that work away from the user.
lobby._serverMessageMembers('roomCreated', cloak.getRooms());
Hi,
I'm trying to get familiar with cloak in case I might use it up and coming node knockout competition (as it looks awesome!).
I want a single node server serving up some pages with express and make use of socket.io. I can do this with straight socket.io, but I'm having problems using cloak in the same way. I've tried the following approach:
var cloak = require('cloak'),
express = require('express'),
app = express();
app.use(express.static(__dirname + '/static'));
var server = require('http').createServer(app);
server.listen(8080);
app.get('/landing', function(req, res) {
res.sendfile(__dirname + '/index.html');
});
cloak.configure({
port: server
});
cloak.run();
My index.html just calls cloak.configure and cloak.run.
I noticed that server side cloak.run just calls listen on socket, and so I passed the server through (like you would if you used straight socket.io).
When the page renders, I get the following error:
'TypeError: Converting circular structure to JSON
at Object.stringify (native)
at Object.exports.encodePacket (/home/roy/src/active/secrets/zamc-cloak/node_modules/socket.io/lib/parser.js:75:19)
at Socket.packet (/home/roy/src/active/secrets/zamc-cloak/node_modules/socket.io/lib/socket.js:212:21)
at Socket.emit (/home/roy/src/active/secrets/zamc-cloak/node_modules/socket.io/lib/socket.js:368:15)
at Socket.<anonymous> (/home/roy/src/active/secrets/zamc-cloak/node_modules/cloak/index.js:103:18)
at Socket.EventEmitter.emit [as $emit] (events.js:95:17)
at SocketNamespace.handlePacket (/home/roy/src/active/secrets/zamc-cloak/node_modules/socket.io/lib/namespace.js:335:22)
at Manager.onClientMessage (/home/roy/src/active/secrets/zamc-cloak/node_modules/socket.io/lib/manager.js:488:38)
at WebSocket.Transport.onMessage (/home/roy/src/active/secrets/zamc-cloak/node_modules/socket.io/lib/transport.js:387:20)
at Parser.<anonymous> (/home/roy/src/active/secrets/zamc-cloak/node_modules/socket.io/lib/transports/websocket/hybi-16.js:39:10)
Should I be able to use express and cloak together in this way? Any ideas where I might be going wrong.
Thanks,
Roy.
we will use reconnectWait to have a timer on this
perhaps "unnamed room"
The following client methods should be removed:
All of these are things that clients should not necessarily be given free reign to do in all games. They make assumptions about what is allowed in the game. For example, a game may have private rooms, so a client listRooms
method would not be appropriate.
Right now rooms have shouldAllowUser
to deal with this problem, but this is not a sustainable approach. This type of logic should go in a custom message handler rather than cluttering the config with new settings.
I realize this makes getting started with Cloak a little harder, but it greatly increases the general usefulness of the library. Most of these methods could be implemented as a message handlers within a handful of lines of code.
The following client functions are not effected.
Since this is not a backward-compatible change this will likely go in a 1.0.0 release.
Interested in your thoughts @dariusk @Cheeseen. Especially since some of these methods came from your work on Grow21, @dariusk .
Sometimes you need to click the create room button multiple times in grow21 before it let you create a room. Not sure what's going on here but we should investigate.
Working on this soon.
Not sure if already implemented, should we close inactive sockets after a certain duration? Inactivity will be determined by no events being sent from the socket for the duration.
eg
process.on('uncaughtException', function (err) {
console.log(err);
});
One alternative we might consider:
http://nodejs.org/api/domain.html#domain_warning_don_t_ignore_errors
No idea why tests are running slower on my faster machine. It seems to pause for a long time during tearDown.
And just use straight websockets without
Subtask of #16
We still need to count up 19/20/22/23 islands in case of a tiebreaker.
19, 23: +2 points
20, 22: +5 points
We can't give users free reign to create as many rooms as they want. This needs to be done in application logic.
Subtask of #16
Should prevent player from playing a card until another player joins. Also: add a player joined notification.
I am making a game in which when I join the room
I want to access the data of all the users currently
in the same room(for sending game invites if I am in the lobby).
but for calling cloak.getRoomMembers(...), I need a room Id
I checked the code and I think there is no any API for that.
I specifically have to ask the server for my room id (EXTRA CODE change also on the server)
so I was suggesting that server should also send an Id with the
room name when it emits joinedRoom serverEvent
line no: https://github.com/incompl/cloak/blob/master/src/server/cloak/room.js#L50
changing to:- user._serverMessage('joinedRoom', _.pick(this, 'name', 'id'));
correct me If it is not a good thing.
Subtask of #16
I want to tag a 1.0.0 with recent changes but beforehand I want to go through and make sure there aren't any other backwards-imcompatible changes I want to make first.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.