Sha256: 51f2e4bf52f7c69e8fe7e7bd0791533d59e0f995b501917d26d5513299701185

Contents?: true

Size: 1015 Bytes

Versions: 1

Compression:

Stored size: 1015 Bytes

Contents

module Angelo

  class WebsocketResponder < Responder

    def params
      @params ||= parse_query_string
      @params
    end

    def request= request
      @params = nil
      @request = request
      @websocket = @request.websocket
      handle_request
    end

    def handle_request
      begin
        if @response_handler
          Angelo.log @connection, @request, @websocket, :switching_protocols
          @bound_response_handler ||= @response_handler.bind @base
          @bound_response_handler[@websocket]
        else
          raise NotImplementedError
        end
      rescue IOError => ioe
        warn "#{ioe.class} - #{ioe.message}"
        close_websocket
      rescue => e
        error e.message
        ::STDERR.puts e.backtrace
        begin
          @connection.close
        rescue Reel::Connection::StateError => rcse
          close_websocket
        end
      end
    end

    def close_websocket
      @websocket.close
      @base.websockets.delete @websocket
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
angelo-0.1.3 lib/angelo/responder/websocket.rb