Created
September 27, 2012 16:41
-
-
Save ritch/3795019 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"type": "MySockets" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
It works perfectly, no need to create a new "MySockets" at /sockets
to get it working, thanks
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?
Look like Script is what i'm looking for: https://github.com/deployd/deployd/blob/master/docs/resources/custom-resources.md#script
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Once you have this running, all you need to do is create a new 'MySockets' at
/sockets
or wherever you want.