Skip to content

Commit

Permalink
setup redirector and make websocket connection use current hostname
Browse files Browse the repository at this point in the history
  • Loading branch information
avalanche123 committed Feb 24, 2012
1 parent 399de3d commit 0abbaaf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion demos/presence/html/js/presence-0.1.0.js
Expand Up @@ -108,7 +108,7 @@ Client.prototype.connect = function() {
return;
}

this.context = new nullmq.Context('ws://localhost:9000');
this.context = new nullmq.Context('ws://'+window.location.hostname+':9000');
this.status = Client.CONNECTING;

this.startSub();
Expand Down
2 changes: 1 addition & 1 deletion demos/presence/python/server.py
Expand Up @@ -87,6 +87,6 @@ def wait_for_reply():
def websocket_handler(websocket, environ):
StompHandler(websocket, ZeroMQBridge()).serve()

server = WebSocketServer(('127.0.0.1', 9000), websocket_handler)
server = WebSocketServer(('0.0.0.0', 9000), websocket_handler)
print "Starting NullMQ-ZeroMQ bridge on 9000"
server.serve_forever()
16 changes: 16 additions & 0 deletions demos/presence/ruby/bin/redirector
@@ -0,0 +1,16 @@
#!/usr/bin/env ruby

require "rubygems"
require "bundler/setup"

require "socket"

server = TCPServer.new(8888)
private_ipv4 = Socket.ip_address_list.detect{|intf| intf.ipv4_private?}.ip_address
puts "starting redirector to #{private_ipv4}:8080"
loop do
client = server.accept
headers = "HTTP/1.1 301 Moved\r\nDate: Tue, 14 Dec 2010 10:48:45 GMT\r\nServer: Ruby\r\nLocation: http://#{private_ipv4}:8080/\r\nContent-length: 0\r\n\r\n"
client.puts headers
client.close
end

0 comments on commit 0abbaaf

Please sign in to comment.