Permalink
Browse files

Merge remote-tracking branch 'origin/master' into networked-gc

Conflicts:
	index.js
	package.json
  • Loading branch information...
thejh committed Nov 16, 2011
2 parents 9a95d7e + 9ed1c70 commit fd13ceced872258316b4d99e742f129225917f39
View
@@ -12,6 +12,7 @@ It works over network sockets and even in the browser with
Plus, there are dnode implementations for
[perl](http://github.com/substack/dnode-perl),
[ruby](http://github.com/substack/dnode-ruby),
+[php](https://github.com/bergie/dnode-php),
and
[java](https://github.com/aslakhellesoy/dnode-java),
so you can glue
@@ -257,10 +258,12 @@ Using [npm](http://npmjs.org):
npm install dnode
-Or check out the repository and link your development copy:
+Or check out the repository and fetch the deps with npm, then build the bundle:
git clone https://github.com/substack/dnode.git
- cd dnode && npm link
+ cd dnode
+ npm install --dev
+ node bin/bundle.js
The dnode dependencies are listed in the
[package.json](https://github.com/substack/dnode/tree/master/package.json).
@@ -294,6 +297,7 @@ between scripts written in different languages.
* [dnode-perl](http://github.com/substack/dnode-perl)
* [dnode-ruby](http://github.com/substack/dnode-ruby)
+* [dnode-php](https://github.com/bergie/dnode-php)
* [dnode-java](https://github.com/aslakhellesoy/dnode-java)
There's a
View
@@ -0,0 +1,21 @@
+var fs = require('fs');
+var path = require('path');
+var browserify = require('browserify');
+
+var src = browserify({ filter : require('uglify-js') })
+ .require(__dirname + '/../browser/index.js')
+ .bundle()
+;
+
+var buf = new Buffer('var DNode = (function () {'
+ + src + '; return require("/index.js")'
++ '})()');
+
+var file = __dirname + '/../browser/bundle.js';
+fs.writeFile(file, buf, function (err) {
+ if (err) console.error('Error: ' + err)
+ else {
+ var bytes = buf.length;
+ console.log(bytes + ' bytes written');
+ }
+});
View
@@ -1,6 +1,7 @@
var protocol = require('dnode-protocol');
var EventEmitter = require('events').EventEmitter;
-var io = require('./socket.io').io;
+var io = require('socket.io-client');
+var json = typeof JSON === 'object' ? JSON : require('jsonify');
var exports = module.exports = dnode;
@@ -23,10 +24,11 @@ dnode.prototype.connect = function () {
var params = protocol.parseArgs(arguments);
var client = self.proto.create();
- if (!params.port) params.port = parseInt(window.location.port, 10);
- if (isNaN(params.port)) delete params.port;
- var sock = client.socketio = new io.Socket(
- params.host || window.location.hostname,
+ var proto = (params.proto || window.location.protocol)
+ .replace(/:.*/, '') + '://';
+
+ var sock = client.socketio = io.connect(
+ proto + (params.host || window.location.host),
params
);
@@ -47,7 +49,7 @@ dnode.prototype.connect = function () {
sock.on('message', client.parse);
client.on('request', function (req) {
- sock.send(JSON.stringify(req) + '\n');
+ sock.send(json.stringify(req) + '\n');
});
if (params.block) {
@@ -59,8 +61,6 @@ dnode.prototype.connect = function () {
this.stack.forEach(function (middleware) {
middleware.call(client.instance, client.remote, client);
});
-
- sock.connect();
};
exports.connect = function () {
Oops, something went wrong.

0 comments on commit fd13cec

Please sign in to comment.