Sha256: 15ede48c2ed45e901f567cab76544abced87594f76e8c12b6bcd2d0f8a463fa1

Contents?: true

Size: 857 Bytes

Versions: 4

Compression:

Stored size: 857 Bytes

Contents

###
WebSocket Interface for the WebSocketRails client.
###
class WebSocketRails.WebSocketConnection extends WebSocketRails.AbstractConnection
  connection_type: 'websocket'
  
  constructor: (@url, @dispatcher) ->
    super
    if @url.match(/^wss?:\/\//)
        console.log "WARNING: Using connection urls with protocol specified is depricated"
    else if window.location.protocol == 'https:'
        @url             = "wss://#{@url}"
    else
        @url             = "ws://#{@url}"
    @_conn           = new WebSocket(@url)
    @_conn.onmessage = (event) => 
      event_data = JSON.parse event.data
      @on_message(event_data)
    @_conn.onclose   = (event) => 
      @on_close(event)
    @_conn.onerror   = (event) => 
      @on_error(event)

  close: ->
    @_conn.close()

  send_event: (event) ->
    super
    @_conn.send event.serialize()

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
wwl-websocket-rails-0.7.3 lib/assets/javascripts/websocket_rails/websocket_connection.js.coffee
wwl-websocket-rails-0.7.2 lib/assets/javascripts/websocket_rails/websocket_connection.js.coffee
wwl-websocket-rails-0.7.1 lib/assets/javascripts/websocket_rails/websocket_connection.js.coffee
websocket-rails-0.7.0 lib/assets/javascripts/websocket_rails/websocket_connection.js.coffee