Sha256: 022005fce8ce02be68de33d52c4957232e875a27dfeeb38fea6f1c0e07b53d1b

Contents?: true

Size: 656 Bytes

Versions: 12

Compression:

Stored size: 656 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

12 entries across 12 versions & 1 rubygems

Version Path
websocket-rails-0.4.7 lib/websocket_rails/connection_adapters/web_socket.rb
websocket-rails-0.4.6 lib/websocket_rails/connection_adapters/web_socket.rb
websocket-rails-0.4.5 lib/websocket_rails/connection_adapters/web_socket.rb
websocket-rails-0.4.4 lib/websocket_rails/connection_adapters/web_socket.rb
websocket-rails-0.4.3 lib/websocket_rails/connection_adapters/web_socket.rb
websocket-rails-0.4.2 lib/websocket_rails/connection_adapters/web_socket.rb
websocket-rails-0.4.1 lib/websocket_rails/connection_adapters/web_socket.rb
websocket-rails-0.4.0 lib/websocket_rails/connection_adapters/web_socket.rb
websocket-rails-0.3.0 lib/websocket_rails/connection_adapters/web_socket.rb
websocket-rails-0.2.1 lib/websocket_rails/connection_adapters/web_socket.rb
websocket-rails-0.2.0 lib/websocket_rails/connection_adapters/web_socket.rb
websocket-rails-0.1.9 lib/websocket_rails/connection_adapters/web_socket.rb