Skip to content
This repository has been archived by the owner on Dec 7, 2018. It is now read-only.

Commit

Permalink
Merge 8fdcc17 into 05a0fca
Browse files Browse the repository at this point in the history
  • Loading branch information
tarcieri committed Apr 5, 2013
2 parents 05a0fca + 8fdcc17 commit 1e7d316
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 19 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
@@ -1,3 +1,7 @@
HEAD
----
* Remove on_error callback system

0.3.0
-----
* Reel::App: Sinatra-like DSL for defining Reel apps using Octarine
Expand Down
19 changes: 4 additions & 15 deletions lib/reel/stream.rb
Expand Up @@ -10,8 +10,10 @@ def call(socket)
end

def write(data)
write! data
self
@socket << data
data
rescue Errno::EPIPE
raise SocketError, "error writing to socket"
end
alias :<< :write

Expand All @@ -20,11 +22,6 @@ def each(*)
yield self
end

def on_error(&proc)
@on_error = proc
self
end

def close
@socket.close unless closed?
end
Expand All @@ -33,14 +30,6 @@ def close
def closed?
@socket.closed?
end

private
def write!(string)
@socket << string
rescue => e
@on_error ? @on_error.call(e) : raise(e)
end

end

class EventStream < Stream
Expand Down
8 changes: 4 additions & 4 deletions lib/reel/websocket.rb
Expand Up @@ -65,9 +65,8 @@ def read_every(n, unit = :s)
def read
@parser.append @socket.readpartial(Connection::BUFFER_SIZE) until msg = @parser.next_message
msg
rescue => e
ensure
cancel_timer!
@on_error ? @on_error.call(e) : raise(e)
end

def body
Expand All @@ -77,9 +76,10 @@ def body
def write(msg)
@socket << ::WebSocket::Message.new(msg).to_data
msg
rescue => e
rescue Errno::EPIPE
raise SocketError, "error writing to socket"
ensure
cancel_timer!
@on_error ? @on_error.call(e) : raise(e)
end
alias_method :<<, :write

Expand Down

0 comments on commit 1e7d316

Please sign in to comment.