lib/angelo/responder/websocket.rb in angelo-0.4.1 vs lib/angelo/responder/websocket.rb in angelo-0.5.0
- old
+ new
@@ -1,30 +1,19 @@
module Angelo
class Responder
class Websocket < Responder
- class << self
-
- attr_writer :on_pong
-
- def on_pong
- @on_pong ||= ->(e){}
- end
-
- end
-
def request= request
@params = nil
@request = request
@websocket = @request.websocket
end
def handle_request
begin
if @response_handler
- Angelo.log @connection, @request, @websocket, :switching_protocols
- @websocket.on_pong &Responder::Websocket.on_pong
+ Angelo.log :ws, @connection, @request, @websocket, :switching_protocols
@base.filter :before
@base.instance_exec(@websocket, &@response_handler)
@base.filter :after
else
raise NotImplementedError
@@ -43,9 +32,11 @@
end
end
def close_websocket
@websocket.close
+ rescue IOError
+ ensure
@base.websockets.remove_socket @websocket
end
end
end