Sha256: 9cb77e9afd527f4728b556848ffca2910ce3b1afdae00363834f89caa6d97c7e

Contents?: true

Size: 680 Bytes

Versions: 4

Compression:

Stored size: 680 Bytes

Contents

module WebsocketRails
  module ConnectionAdapters
    class WebSocket < Base
      
      def self.accepts?(env)
        Faye::WebSocket.websocket?( env )
      end
      
      def initialize(request,dispatcher)
        super
        @connection = Faye::WebSocket.new( request.env )
        @connection.onmessage = method(:on_message)
        @connection.onerror   = method(:on_error)
        @connection.onclose   = method(:on_close)
        on_open
      end
      
      def send(message)
        @connection.send message
      end

      def on_message(event)
        data = event.respond_to?(:data) ? event.data : event
        super data
      end
      
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
websocket-rails-0.1.8 lib/websocket_rails/connection_adapters/web_socket.rb
websocket-rails-0.1.7 lib/websocket_rails/connection_adapters/web_socket.rb
websocket-rails-0.1.6 lib/websocket_rails/connection_adapters/web_socket.rb
websocket-rails-0.1.5 lib/websocket_rails/connection_adapters/web_socket.rb