Sha256: 08deaf7b6f3e953ecff9deff83bace4f02b664ed98e9c208cb346672b75447f6

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

module Angelo
  class Responder
    class Websocket < Responder

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

      def handle_request
        begin
          if @response_handler
            Angelo.log :ws, @connection, @request, @websocket, :switching_protocols
            @base.filter :before
            @base.instance_exec(@websocket, &@response_handler)
            @base.filter :after
          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::StateError => rcse
            close_websocket
          end
        end
      end

      def close_websocket
        @websocket.close
      rescue IOError
      ensure
        @base.websockets.remove_socket @websocket
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
angelo-0.5.1 lib/angelo/responder/websocket.rb
angelo-0.5.0 lib/angelo/responder/websocket.rb