Skip to content

Instantly share code, notes, and snippets.

@ritch
Created September 27, 2012 16:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ritch/3795019 to your computer and use it in GitHub Desktop.
Save ritch/3795019 to your computer and use it in GitHub Desktop.
{
"type": "MySockets"
}
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript" src="dpd.js"></script>
</head>
<body>
<script>
dpd.on('my event', function (data) {
$('body').append(JSON.stringify(data));
});
</script>
</body>
</html>
var Resource = require('deployd/lib/resource')
, util = require('util');
function MySockets(name, options) {
Resource.apply(this, arguments);
var server = options.server;
server.sockets.once('connection', function (socket) {
socket.emit('my event', 'hello first socket!');
});
}util.inherits(MySockets, Resource);
module.exports = MySockets;
@ritch
Copy link
Author

ritch commented Sep 27, 2012

Once you have this running, all you need to do is create a new 'MySockets' at /sockets or wherever you want.

@julesbou
Copy link

It works perfectly, no need to create a new "MySockets" at /sockets to get it working, thanks

@julesbou
Copy link

It seems MySockets is re-instanciated each time i grab another resource, do you have an idea for it, to be like a long running process?

@julesbou
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment