Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Websockets impl throws custom errors.

  • Loading branch information...
commit 42bf358999122a3bb5be4636fcb36d6c216f6ccf 1 parent 55ca89a
Steven Shingler authored December 30, 2010
2  Gemfile.lock
... ...
@@ -1,7 +1,7 @@
1 1
 PATH
2 2
   remote: .
3 3
   specs:
4  
-    rsift (0.3.2)
  4
+    rsift (0.3.4)
5 5
       em-http-request (= 0.2.15)
6 6
       jakal (= 0.1.95)
7 7
       json (= 1.4.6)
24  lib/rsift/socket.rb
@@ -3,21 +3,33 @@
3 3
 module Rsift
4 4
 
5 5
   class Socket
6  
-  
  6
+
7 7
     def self.perform(stream_identifier)
8 8
       endpoint = "ws://stream.datasift.net:8080/"
  9
+
9 10
       EventMachine.run {
10 11
         http = EventMachine::HttpRequest.new(
11 12
             "#{endpoint}#{stream_identifier}").get(:timeout => 0)
12  
-    
13  
-        http.callback { puts "Connected to datasift" }
14  
-        http.errback { puts "something has failed" }
15  
-        http.disconnect { puts "oops, dropped connection?" }
16  
-    
  13
+
  14
+        http.callback do
  15
+          puts "Connected to datasift" 
  16
+        end
  17
+        
  18
+        http.errback do 
  19
+          raise SocketDisconnect.new("Datasift threw an error")
  20
+        end
  21
+        
  22
+        http.disconnect do
  23
+           raise SocketDisconnect.new("Datasift disconnected me.")
  24
+        end
  25
+
17 26
         http.stream { |msg|
18 27
           yield msg
19 28
         }
20 29
       }
21 30
     end
22 31
   end
  32
+  
  33
+  class SocketDisconnect < StandardError; end
  34
+  class SocketError < StandardError; end
23 35
 end
2  lib/rsift/version.rb
... ...
@@ -1,3 +1,3 @@
1 1
 module Rsift
2  
-  VERSION = "0.3.3"
  2
+  VERSION = "0.3.4"
3 3
 end

0 notes on commit 42bf358

Please sign in to comment.
Something went wrong with that request. Please try again.