fixed not hardcoded port for websockets
This commit is contained in:
parent
4cd90a16a1
commit
94de043862
2 changed files with 19 additions and 2 deletions
|
|
@ -19,12 +19,29 @@
|
||||||
WebSocket.__swfLocation = "/javascripts/WebSocketMain.swf";
|
WebSocket.__swfLocation = "/javascripts/WebSocketMain.swf";
|
||||||
|
|
||||||
|
|
||||||
= javascript_include_tag 'socket' if user_signed_in?
|
|
||||||
= csrf_meta_tag
|
= csrf_meta_tag
|
||||||
= yield(:head)
|
= 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
|
:javascript
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
|
|
||||||
$('a').hover(function(){
|
$('a').hover(function(){
|
||||||
$(this).fadeTo(60, 0.5);
|
$(this).fadeTo(60, 0.5);
|
||||||
}, function(){
|
}, function(){
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
function debug(str){ $("#debug").append("<p>" + str); };
|
function debug(str){ $("#debug").append("<p>" + str); };
|
||||||
|
|
||||||
ws = new WebSocket("ws://localhost:8080/");
|
ws = new WebSocket("ws://localhost:8080/");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue