Permalink
Browse files

initial test of plugin with mtgox websocket

  • Loading branch information...
1 parent 45336f0 commit 6e71af3dc11e260a8856fe97cb2d6480ffd4c1e8 cronopio committed Sep 14, 2011
Showing with 45 additions and 3 deletions.
  1. +2 −0 .gitignore
  2. +1 −0 bin/config.json
  3. +11 −0 bin/hookws
  4. +29 −1 lib/hookws.js
  5. +2 −2 package.json
View
@@ -0,0 +1,2 @@
+gmon.out
+node_modules/
View
@@ -0,0 +1 @@
+{}
View
@@ -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();
View
@@ -3,5 +3,33 @@
*/
var Hook = require('hook.io').Hook,
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);
View
@@ -1,7 +1,7 @@
{
"author": "Daniel Aristizabal <aristizabal.daniel@gmail.com>",
"name": "hook.io-ws",
- "description": "hook for websocket connection"
+ "description": "hook for websocket connection",
"version": "0.0.1",
"repository": {
"type": "git",
@@ -13,6 +13,6 @@
},
"dependencies": {
"hook.io": "0.6.x"
- }
+ },
"devDependencies": {}
}

0 comments on commit 6e71af3

Please sign in to comment.