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
dojo.provide("dojo.socket"); | |
dojo.socket = function(/*dojo.__XhrArgs*/ argsOrUrl){ | |
// summary: | |
// Provides a simple socket connection using WebSocket or long-polling based | |
// communication in legacy browsers for comet-style communication. This is based | |
// on the WebSocket API and returns an object that implements the WebSocket interface: | |
// http://dev.w3.org/html5/websockets/#websocket | |
// argsOrUrl: | |
// This uses the same arguments as the other I/O functions in Dojo, or a |
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
node>when = require("promised-io/promise").when; | |
[Function] | |
node>defer = require("promised-io/promise").defer; | |
[Function] | |
node>d = defer(); | |
node>when(when(d.promise,function(){},function(){return 5}),function(){print("su | |
ccess");}); | |
{ then: [Function] } | |
node>d.reject("error"); |
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 request = require("rhino-http-client").request; | |
var r = request({url:"http://www.google.com"}); | |
r.then(function(r){ | |
print("status: " + r.status); | |
r.body.forEach(function(){ | |
print("part") | |
}).then(function(){ | |
print("done"); | |
}) | |
}); |
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
/** | |
* This is an example Wiki web application written on Pintura | |
*/ | |
var pageFacets = require("./facet/page"), | |
pageChangeFacets = require("./facet/page-change"), | |
admins = require("commonjs-utils/settings").security.admins, | |
fullModel = require("./model/index"), | |
Package = require("perstore/model").Package, | |
copy = require("commonjs-utils/copy").copy, | |
Register = require("pintura/security").Register; |
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
on the client side: | |
function monitor(){ | |
dojo.xhr({ | |
method:"POST", | |
url:"/TestCalls", | |
headers:{ | |
"Accept":"message/json", | |
"Content-Type":"message/json" | |
}, | |
postData: dojo.toJson([{method:"subscribe", subscribe:"hour"}]), |
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
query = and | |
# Normalized components | |
nchar = unreserved / pct-encoded | |
name = *nchar | |
value = *nchar / typed-value / array | |
typed-value = *nchar ":" *nchar | |
array = "(" [ value *( "," value ) ] ")" | |
call = name "(" [ argument *( "," argument ) ] ")" | |
argument = call / value |
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 server = require("http").createServer(function(request, response){ | |
}); | |
var nodes = require("./multi-node").listen({ | |
port: 80, | |
nodes: 4 | |
}, server); | |
nodes.addListener("node", function(stream){ | |
stream.write("hello"); | |
}); |
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
Error: Stream is not writable | |
at Stream._writeOut (net:689:11) | |
at Stream.write (net:675:17) | |
at EventEmitter.<anonymous> (file:///Volumes/Persevere/example/lib/index.js:40:9) | |
EventEmitter.emit (events:25:26) | |
at Stream.<anonymous> (jar:http://github.com/kriszyp/multi-node/zipball/master!/lib/multi-node.js:30:16) | |
at Stream.emit (events:25:26) | |
at net:302:16 | |
at EventEmitter._tickCallback (node.js:48:25) | |
at node.js:221:9 |
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 pinturaNodeApp = require("jsgi-node").Listener(pinturaApp); | |
run: () -> | |
http: require 'http' | |
server: http.createServer (request, response) -> | |
#sys.debug sys.inspect request | |
# separate handlers for high-load paths | |
if request.url is '/hello' | |
hello.call response | |
else if request.url is '/test' | |
redirector.call response, rnd() |
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
require.define({ | |
"promise":function(require, exports, module) { | |
// Kris Zyp | |
// this is based on the CommonJS spec for promises: | |
// http://wiki.commonjs.org/wiki/Promises | |
// Includes convenience functions for promises, much of this is taken from Tyler Close's ref_send | |
// and Kris Kowal's work on promises. | |
// // MIT License |