Last active
February 12, 2016 15:11
-
-
Save erayarslan/d3ef5b10969ca4e5be4e to your computer and use it in GitHub Desktop.
spachcock ws example
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 WebSocket = require('ws'); | |
| var Spachcock = require("spachcock"); | |
| var ws = new WebSocket('ws://echo.websocket.org'); | |
| var $ = new Spachcock(); | |
| $.route("/:first/:second", function (req, res) { | |
| console.log(req.params); | |
| }); | |
| $.response = ws.send; | |
| Spachcock.prototype.parser = function (data) { | |
| return data; | |
| }; | |
| $.listen(); | |
| ws.on('open', function() { | |
| ws.send('/hello/world'); | |
| }); | |
| ws.on('message', function(data, flags) { | |
| $.handle(data); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment