Skip to content

Commit

Permalink
initial test of plugin with mtgox websocket
Browse files Browse the repository at this point in the history
  • Loading branch information
cronopio committed Sep 14, 2011
1 parent 45336f0 commit 6e71af3
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
gmon.out
node_modules/
1 change: 1 addition & 0 deletions bin/config.json
@@ -0,0 +1 @@
{}
11 changes: 11 additions & 0 deletions bin/hookws
@@ -0,0 +1,11 @@
#!/usr/bin/env node

var WebSocketHook = require('../lib/hookws').HookSocket;

var mtgoxTest = new WebSocketHook({
name: 'mtgox',
url:'ws://websocket.mtgox.com/mtgox',
debug:true
});

mtgoxTest.start();
30 changes: 29 additions & 1 deletion lib/hookws.js
Expand Up @@ -3,5 +3,33 @@
*/ */
var Hook = require('hook.io').Hook, var Hook = require('hook.io').Hook,
util = require('util'), util = require('util'),
WebSocket = require('./websocket'); WebSocket = require('./websocket').WebSocket;


var HookSocket = exports.HookSocket = function(options){
Hook.call(this, options);
var self = this;

self.on('hook::ready', function(){
console.log('Iniciando');
console.log(options);
var ws = new WebSocket(options.url);

ws.on('open', function(){
self.emit('websocket::connected');
});

ws.on('message', function(msg){
self.emit('websocket::message',msg);
});

ws.on('wserror', function(e){
self.emit('websocket::error', e);
});

ws.on('close', function(){
self.emit('websocket::close');
});
});
};

util.inherits(HookSocket, Hook);
4 changes: 2 additions & 2 deletions package.json
@@ -1,7 +1,7 @@
{ {
"author": "Daniel Aristizabal <aristizabal.daniel@gmail.com>", "author": "Daniel Aristizabal <aristizabal.daniel@gmail.com>",
"name": "hook.io-ws", "name": "hook.io-ws",
"description": "hook for websocket connection" "description": "hook for websocket connection",
"version": "0.0.1", "version": "0.0.1",
"repository": { "repository": {
"type": "git", "type": "git",
Expand All @@ -13,6 +13,6 @@
}, },
"dependencies": { "dependencies": {
"hook.io": "0.6.x" "hook.io": "0.6.x"
} },
"devDependencies": {} "devDependencies": {}
} }

0 comments on commit 6e71af3

Please sign in to comment.