Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Owen Barnes
committed
Jun 23, 2011
1 parent
38d3bbd
commit 9bc15d7
Showing
20 changed files
with
165 additions
and
410 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"version":{"server":"0.0.54","client":"0.0.15"}} | ||
{"version":{"server":"0.1.00","client":"0.0.17"}} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,34 @@ | ||
exports.init = -> if SS.client.browser.isSupported() then loadApp() else SS.client.browser.showIncompatibleMessage() | ||
# Client-side code | ||
|
||
loadApp = -> | ||
# This function is called automatically once the websocket is setup | ||
exports.init = -> | ||
$('.message.template').hide() | ||
SS.server.app.init (user) -> if user then $('#main').show() else displaySignInForm() | ||
SS.server.app.init (user) -> | ||
if user then $('#main').show() else displaySignInForm() | ||
|
||
# Bind to Submit button | ||
$('form#sendMessage').submit -> | ||
newMessage = $('#newMessage').val() | ||
SS.server.app.sendMessage newMessage, (response) -> if response.error then alert(response.error) else $('#newMessage').val('') | ||
SS.server.app.sendMessage newMessage, (response) -> | ||
if response.error then alert(response.error) else $('#newMessage').val('') | ||
false | ||
SS.events.on 'newMessage', (params) -> renderMessage(params) | ||
|
||
|
||
# Bind to new incoming message event | ||
SS.events.on 'newMessage', renderMessage | ||
|
||
|
||
# PRIVATE | ||
|
||
displaySignInForm = -> | ||
$('#signIn').show().submit -> | ||
SS.server.app.signIn $('#signIn').find('input').val(), (response) -> $('#signInError').remove() and if response is false then $('#signIn').append("<p id='signInError'>The name you provided was incorrect. Sorry.</p>").find('input').val('') else displayMainScreen() | ||
SS.server.app.signIn $('#signIn').find('input').val(), (response) -> | ||
$('#signInError').remove() | ||
displayMainScreen() | ||
false | ||
|
||
displayMainScreen = -> $('#signIn').fadeOut(230) and $('#main').show() | ||
displayMainScreen = -> | ||
$('#signIn').fadeOut(230) and $('#main').show() | ||
|
||
renderMessage = (params) -> $('.message').clone().find('.body').html(params.body).parent().find('.user').html(params.cdid).parent().appendTo("#messages").show() and SS.client.scroll.down('#messages', 450) | ||
renderMessage = (params) -> | ||
$('#templates-message').tmpl(params).appendTo('#messages') | ||
SS.client.scroll.down('#messages', 450) |
This file was deleted.
Oops, something went wrong.
This file contains 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 file contains 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 file contains 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 file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
# Server-side code | ||
|
||
exports.actions = | ||
|
||
init: (cb) -> | ||
if @session.user_id | ||
R.get "user:#{@session.user_id}", (err, data) => if data then cb data else cb false | ||
R.get "user:#{@session.user_id}", (err, data) => | ||
if data then cb data else cb false | ||
else | ||
cb false | ||
|
||
sendMessage: (message, cb) -> | ||
if message | ||
SS.publish.broadcast 'newMessage', {cdid: @session.user_id, body: message} | ||
cb true | ||
else | ||
cb false | ||
# TODO: Check messages for malformed content, HTML tags, etc | ||
SS.publish.broadcast 'newMessage', {user: @session.user_id, body: message} | ||
cb true | ||
|
||
signIn: (cdid, cb) -> R.get "user:#{cdid}", (err, cached_user_data) => R.set "user:#{cdid}", "user:#{cdid}", (err, data) => cb "user:#{cdid}" | ||
signIn: (user, cb) -> | ||
@session.setUserId(user) | ||
cb user |
This file was deleted.
Oops, something went wrong.
This file contains 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 file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
.message.template | ||
.message | ||
.user | ||
{{= user}} | ||
.body | ||
{{= body}} |
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,15 @@ | ||
{"limiter":{"enable":true,"websockets":{"rps":10}},"redis":{"db_index":1}} | ||
{ | ||
"http": { | ||
"port": 3000, | ||
"hostname": "0.0.0.0" | ||
}, | ||
"https": { | ||
"enabled": false, | ||
"port": 443, | ||
"domain": "www.socketstream.org" | ||
}, | ||
"browser_check": { | ||
"enabled": true, | ||
"strict": true | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# HTTP Router Config | ||
# ------------------ | ||
|
||
# This file defines how incoming HTTP requests are handled | ||
# Note: The default configuration will probably change a lot in the future. Be warned! | ||
|
||
exports.call = (request, response, next) -> | ||
|
||
# Custom Middleware | ||
# ----------------- | ||
|
||
# Hook-in your own custom HTTP middleware to modify or respond to requests before they're passed to the SocketStream HTTP stack | ||
# See README for more details and example middleware code | ||
|
||
# require('my_middleware').call request, response, next | ||
|
||
|
||
# Unless you're passing the callback to custom middleware, you'll need to call next() here | ||
next() | ||
|
Oops, something went wrong.