Permalink
Browse files

Initial project commit.

  • Loading branch information...
0 parents commit c2bdf5bbc4155ac6ef3f91eb60457b39c99b6492 @jsgoecke jsgoecke committed Nov 22, 2010
@@ -0,0 +1,2 @@
+---
+BUNDLE_DISABLE_SHARED_GEMS: "1"
12 Gemfile
@@ -0,0 +1,12 @@
+source 'http://rubygems.org'
+
+group :production do
+ gem 'eventmachine'
+ gem 'em-websocket'
+ gem 'awesome_print'
+ gem 'json'
+end
+
+group :development, :test, :production do
+ gem 'web-socket-ruby'
+end
@@ -0,0 +1,15 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ addressable (2.2.2)
+ em-websocket (0.1.4)
+ addressable (>= 2.1.1)
+ eventmachine (>= 0.12.9)
+ eventmachine (0.12.10)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ em-websocket
+ eventmachine
@@ -0,0 +1,16 @@
+Tropo WebSocket Relay
+=====================
+
+A server that will act as a relay between Tropo and an application using WebSockets. This may be used for applications that require low-latency, where HTTP POSTS are too slow, persistent TCP connections between Tropo and their backend applciations.
+
+Installation
+============
+
+* git clone git://github.com/tropo/tropo-websockets.git
+* bundle install
+
+Running
+=======
+
+* ruby tropo-websockets.rb
+
@@ -0,0 +1,8 @@
+websocket:
+ :host: 0.0.0.0
+ :port: 8082
+ :debug: true
+ :secure: false
+ # :tls_options:
+ # :private_key_file: keys/key
+ # :cert_chain_file: keys/cert
@@ -0,0 +1,14 @@
+require 'rubygems'
+require 'web_socket'
+require 'json'
+require 'awesome_print'
+
+# Connects to Web Socket server at host example.com port 10081.
+client = WebSocket.new("ws://0.0.0.0:8082")
+# Sends a message to the server.
+10.times do
+ msg = { :type => 'publisher', :id => '1234', :data => { :ani => rand(10000).to_s, :command => '*' } }
+ ap msg
+ client.send msg.to_json
+end
+
@@ -0,0 +1,12 @@
+require 'rubygems'
+require 'web_socket'
+require 'awesome_print'
+require 'json'
+
+# Connects to Web Socket server at host example.com port 10081.
+client = WebSocket.new("ws://0.0.0.0:8082")
+# Sends a message to the server.
+client.send({ :type => 'subscriber', :id => 'tropo-app1' }.to_json)
+while data = client.receive()
+ ap JSON.parse data
+end
Oops, something went wrong.

0 comments on commit c2bdf5b

Please sign in to comment.