From 94de043862012c518be7e90b6868cf9eb3e79a8f Mon Sep 17 00:00:00 2001 From: maxwell <maxwell@joindiaspora.com> Date: Tue, 22 Jun 2010 17:20:07 -0700 Subject: [PATCH] fixed not hardcoded port for websockets --- app/views/layouts/application.html.haml | 19 ++++++++++++++++++- public/javascripts/socket.js | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index c785e5d03f..4b2ab38800 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -19,12 +19,29 @@ WebSocket.__swfLocation = "/javascripts/WebSocketMain.swf"; - = javascript_include_tag 'socket' if user_signed_in? = csrf_meta_tag = yield(:head) + - if user_signed_in? + :javascript + $(document).ready(function(){ + function debug(str){ $("#debug").append("<p>" + str); }; + + ws = new WebSocket("ws://#{request.host}:8080/"); + ws.onmessage = function(evt) { + $("#stream").prepend($(evt.data).fadeIn("fast")); + }; + ws.onclose = function() { debug("socket closed"); }; + ws.onopen = function() { + debug("connected..."); + //ws.send("hello server"); + // ws.send("hello again"); + }; + }); + :javascript $(document).ready(function(){ + $('a').hover(function(){ $(this).fadeTo(60, 0.5); }, function(){ diff --git a/public/javascripts/socket.js b/public/javascripts/socket.js index 6f66507f37..7db6c91309 100644 --- a/public/javascripts/socket.js +++ b/public/javascripts/socket.js @@ -1,4 +1,4 @@ - $(document).ready(function(){ +$(document).ready(function(){ function debug(str){ $("#debug").append("<p>" + str); }; ws = new WebSocket("ws://localhost:8080/"); -- GitLab