UNPKG

phantom-socketio

Version:

This simple library provides the ability to use socket.io-client library inside phantomjs.

18 lines (13 loc) 558 B
var phantomSocket = require('../index.js'); var fs = require('fs'); var system = require('system'); var simpleJsPath = system.args[0]; var indexJsDirectoryPath = simpleJsPath.substring(0, simpleJsPath.lastIndexOf(fs.separator)) + fs.separator + '..'; phantomSocket.initialize(indexJsDirectoryPath, 'http://localhost:3000', function () { var count = 0; phantomSocket.on('messageFromNode', function(data){ console.log('Message from node received', data); phantomSocket.emit('messageFromPhantom', count) count++; }); });