Permalink
Browse files

READY

  • Loading branch information...
1 parent 00bfd87 commit 968d9a224cd4b766e8decf6eb6cbcca8a0d4d613 @dominictarr committed May 31, 2012
Showing with 40 additions and 12 deletions.
  1. +12 −11 index.js
  2. +1 −1 package.json
  3. +27 −0 src/sockjs-0.3.min.js
View
@@ -2,6 +2,14 @@
I keep forgetting how to
setup websocket apps.
*/
+var path = require('path')
+var fs = require('fs')
+var sockjs = require('sockjs')
+var connect = require('connect')
+var browserify = require('browserify')
+var toEmitter = require('reconnector')
+
+module.exports = createServer
function defaults (obj, defaults) {
obj = obj || {}
@@ -21,13 +29,6 @@ function defaults (obj, defaults) {
but that is what I'm all about.
*/
-var path = require('path')
-var fs = require('fs')
-var sockjs = require('sockjs')
-var connect = require('connect')
-var browserify = require('browserify')
-var toEmitter = require('reconnector/ws-server')
-
function createServer(opts) {
opts = defaults(opts, {
url: '/skates',
@@ -54,17 +55,17 @@ function createServer(opts) {
//from this server
browser.prepend([
- 'window.RECONNECTOR = ' + JSON.stringify({
+ 'window.SKATES = ' + JSON.stringify({
timestamp: app.timestamp = Date.now(), //this is the version of the code you are on
url: opts.url
})
//it will be useful to pass initialization data on the connection, too.
,
- 'window.RECONNECTOR.create = ' + function () {
- return new SockJS(RECONNECTOR.url)
+ 'window.SKATES.create = ' + function () {
+ return new SockJS(SKATES.prefix || SKATES.url)
}.toString() + ';'
].join('\n'))
- browser.prepend(fs.readFileSync('../src/sockjs-0.3.min.js'))
+ browser.prepend(fs.readFileSync(__dirname + '/src/sockjs-0.3.min.js'))
/*
REMEMBER to make sure that the javascript gets served.
maybe inject it into the page?
View
@@ -17,6 +17,6 @@
"optionalDependencies": {},
"engines": {
"node": "*"
- }
+ },
"browserify": "./client.js"
}
Oops, something went wrong.

0 comments on commit 968d9a2

Please sign in to comment.