Sha256: 53063d91e14454cdcbd357af8f0a99c0b9db384412fdefdab113573dd3c149d2

Contents?: true

Size: 901 Bytes

Versions: 21

Compression:

Stored size: 901 Bytes

Contents

###
The Event object stores all the relevant event information.
###

class WebSocketRails.Event

  constructor: (data,@success_callback,@failure_callback) ->
    @name    = data[0]
    attr     = data[1]
    if attr?
      @id      = if attr['id']? then attr['id'] else (((1+Math.random())*0x10000)|0)
      @channel = if attr.channel? then attr.channel
      @data    = if attr.data? then attr.data else attr
      @connection_id = data[2]
      if attr.success?
        @result  = true
        @success = attr.success

  is_channel: =>
    @channel?

  is_result: =>
    @result == true

  is_ping: =>
    @name == 'websocket_rails.ping'

  serialize: =>
      JSON.stringify [@name, @attributes()]

  attributes: =>
    id: @id,
    channel: @channel,
    data: @data

  run_callbacks: (success,data) =>
    if success == true
      @success_callback?(data)
    else
      @failure_callback?(data)

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
websocket-rails-0.6.2 lib/assets/javascripts/websocket_rails/event.js.coffee
websocket-rails-0.6.1 lib/assets/javascripts/websocket_rails/event.js.coffee
websocket-rails-0.6.0 lib/assets/javascripts/websocket_rails/event.js.coffee
websocket-rails-0.5.0 lib/assets/javascripts/websocket_rails/event.js.coffee
websocket-rails-0.4.9 lib/assets/javascripts/websocket_rails/event.js.coffee
websocket-rails-0.4.8 lib/assets/javascripts/websocket_rails/event.js.coffee
websocket-rails-0.4.7 lib/assets/javascripts/websocket_rails/event.js.coffee
websocket-rails-0.4.6 lib/assets/javascripts/websocket_rails/event.js.coffee
websocket-rails-0.4.5 lib/assets/javascripts/websocket_rails/event.js.coffee
websocket-rails-0.4.4 lib/assets/javascripts/websocket_rails/event.js.coffee
websocket-rails-0.4.3 lib/assets/javascripts/websocket_rails/event.js.coffee
websocket-rails-0.4.2 lib/assets/javascripts/websocket_rails/event.js.coffee
websocket-rails-0.4.1 lib/assets/javascripts/websocket_rails/event.js.coffee
websocket-rails-0.4.0 lib/assets/javascripts/websocket_rails/event.js.coffee
websocket-rails-0.3.0 lib/assets/javascripts/websocket_rails/event.js.coffee
websocket-rails-0.2.1 lib/assets/javascripts/websocket_rails/event.js.coffee
websocket-rails-0.2.0 lib/assets/javascripts/websocket_rails/event.js.coffee
websocket-rails-0.1.9 lib/assets/javascripts/websocket_rails/event.js.coffee
websocket-rails-0.1.8 lib/assets/javascripts/websocket_rails/event.js.coffee
websocket-rails-0.1.7 lib/assets/javascripts/websocket_rails/event.js.coffee