Skip to content

Commit

Permalink
0.0.53
Browse files Browse the repository at this point in the history
  • Loading branch information
Owen Barnes committed Jun 8, 2011
1 parent 925f2e0 commit 66a3460
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 56 deletions.
9 changes: 9 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
0.0.53 / 2011-06-08
===================

* Calls to SS.server actions from the browser will automatically output to the browser's console if no callback function is provided (makes testing/debugging SS.server actions much easier!)
* Heartbeats from the client are now sent and processed more efficiently
* The HTML output now lists links to CSS files before JavaScript files, as recommended by the Chrome Audit tool
* Updated the README


0.0.52 / 2011-06-07
===================

Expand Down
79 changes: 48 additions & 31 deletions README.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ TODO

List of minor tasks to be done soon or already in progress:

* Improve generated 'new project' code
* Clean up API code - get rid of url_lib
* Fix errors generated in Firefox when server connection is dropped (does not affect reconnect)
* Refactor coffee compile so we don't repeat ourselves
* Make sure "#{system_path}/cached/lib.min.js" can be read when npm package is installed instead of linked
* Can we easily add gzip compression to static assets?
17 changes: 9 additions & 8 deletions lib/asset/compile.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,20 @@ exports.compile =

# Always include links to JS and CSS client-side pre-packed libraries
inclusions = []
inclusions.push(tag.js('assets', exports.assets.files.js.lib))

# Include CSS
inclusions.push(tag.css('assets', exports.assets.files.css.lib))
if SS.config.pack_assets
inclusions.push(tag.css('assets', exports.assets.files.css.app))
else
inclusions.push(tag.css('css', 'app.styl')) # additional files should be linked from app.styl

# Typically when in Staging or Production assets are pre-packed, so we include links to them here
# Include JS
inclusions.push(tag.js('assets', exports.assets.files.js.lib))
if SS.config.pack_assets
inclusions.push(tag.js('assets', exports.assets.files.js.app))
inclusions.push(tag.css('assets', exports.assets.files.css.app))
# However, when in Development, we need to iterate through all dirs and include separate links to load each file
else
# Include client-side and shared CoffeeScript
# When in Development/Staging, we need to iterate through all dirs and include separate links to load each file
exports.assets.client_dirs.map (dir) ->
path = "app/#{dir}"
files = file_utils.readDirSync(path).files
Expand All @@ -36,9 +40,6 @@ exports.compile =
files.map (file) ->
file = file.replace(path + '/', '')
inclusions.push(tag.js(dir, file))

# Include Stylus files (additional files should be linked from app.styl)
inclusions.push(tag.css('css', 'app.styl'))

# Include all jQuery templates, if present
inclusions = inclusions.concat(buildTemplates())
Expand Down
2 changes: 1 addition & 1 deletion lib/client/cached/lib.min.js

Large diffs are not rendered by default.

28 changes: 15 additions & 13 deletions lib/client/socketstream.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,24 @@ SS.socket.on 'disconnect', ->
# Connect!
SS.socket.connect()

# Define the default callback - simply to console.log out the server's response. Used for debugging from the console
default_cb = (server_response) -> console.log(server_response)

# Sends a command to /app/server code
# Important: This global method should no longer be used directly. It will be renamed/removed in a future release
# Instead call SS.server followed by the remote function you wish to invoke
window.remote = ->
SS.internal.remote = ->
args = arguments

# Assemble message
msg = {type: 'server'}
msg.method = args[0]
msg.method = "#{SS.config.remote_prefix}.#{msg.method}" if SS.config.remote_prefix
msg.params = if args.length >= 3 then args[1] else null
msg.params = args[1]
msg.options = if args.length >= 4 then args[2] else null

# The callback is always the last argument passed
cb = args[args.length - 1]
# Test to see if the last argument passed is a callback function. It should be, however if we're just testing
# out a function from the browser's console, use the default callback which simply console.log's the response
last_arg = args[args.length - 1]
cb = if typeof(last_arg) == 'function' then last_arg else default_cb
cb.options = msg.options

# Log if in Developer mode, then send
Expand Down Expand Up @@ -186,7 +188,7 @@ start = ->
app.init()
SS.started = new Date

send = (msg, cb) ->
send = (msg, cb = null) ->
args = arguments
try
if (SS.socket.connected == false && SS.socket.connecting == false)
Expand All @@ -195,9 +197,10 @@ send = (msg, cb) ->
throw 'NOT_READY'
else
if SS.socket.ready == true
cb_id = Math.random().toString().split('.')[1]
window.SS.internal.cb_stack[cb_id] = {funkt: cb, msg: msg}
msg.cb_id = cb_id
if cb
cb_id = Math.random().toString().split('.')[1]
SS.internal.cb_stack[cb_id] = {funkt: cb, msg: msg}
msg.cb_id = cb_id
msg = JSON.stringify(msg)
SS.socket.send(msg)
else
Expand Down Expand Up @@ -233,9 +236,8 @@ setupAPI = (root, ary) ->
if typeof(value) == 'object'
setupAPI(root[key], ns)
else
# For now we just pass the command through to the existing 'remote' function. This will be refactored in the future
root[key] = new Function('remote.apply(window, ["' + ns.join('.') + '"].concat(Array.prototype.slice.call(arguments, 0)))')
root[key] = new Function('SS.internal.remote.apply(window, ["' + ns.join('.') + '"].concat(Array.prototype.slice.call(arguments, 0)))')

sendHeartbeat = ->
send {type: 'heartbeat'}, ->
send({type: 'heartbeat'}) if SS.socket.connected
setTimeout arguments.callee, (SS.config.heartbeat_interval * 1000)
2 changes: 1 addition & 1 deletion lib/generator_files/app.jade
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ html(lang: "en")
title Welcome
body
#content
img(src: '/images/logo.png', alt: 'SocketStream Logo')
img(src: '/images/logo.png', alt: 'SocketStream Logo', width: 167, height: 159)
h1 Welcome to your new real time app!
p#message Attempting to connect to the server over websockets or flashsockets...
|Until we make this the beautiful, helpful starter page it should be, please check out the docs on
Expand Down
3 changes: 3 additions & 0 deletions lib/logger.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ exports.incoming =
rpsExceeded: (client) ->
output 2, "ALERT: Subsequent requests from Client ID: #{client.sessionId}, Session ID: #{client.session.id}, IP: #{client.connection.remoteAddress} will be dropped as requests-per-second over #{SS.config.limiter.websockets.rps}"

rawMessage: (data, client) ->
output 5, "DEBUG: Raw message from #{client.sessionId} - #{data}"

exports.outgoing =

socketio: (msg, client) ->
Expand Down
2 changes: 1 addition & 1 deletion lib/main.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ exports.init = (load_project = false) ->
SS.version = SS.internal.package_json.version

# Set client file version. Bumping this automatically triggers re-compliation of lib assets when a user upgrades
SS.client.version = '0.0.14'
SS.client.version = '0.0.15'

# Set environment
env = process.env.SS_ENV || 'development'
Expand Down
3 changes: 3 additions & 0 deletions lib/server.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ process =

# Called each time Socket.IO sends a message through to the server
call: (data, client) ->

# Log each message for debugging (only when log_level >= 5)
SS.log.incoming.rawMessage(data, client)

# Silently drop all calls if...
return null if client.rps_exceeded # client has exceeded the number of requests-per-second
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "socketstream",
"description": "Build phenomenally fast real-time apps on Node.js",
"version": "0.0.52",
"version": "0.0.53",
"homepage": "http://www.socketstream.org",
"author": "Owen Barnes <info@socketstream.org>",
"contributors": [
Expand Down

0 comments on commit 66a3460

Please sign in to comment.