Sha256: 31fbcd54faed9321dfedff9d384a52376352a6291c21f04ca245f77e848fa484

Contents?: true

Size: 1004 Bytes

Versions: 1

Compression:

Stored size: 1004 Bytes

Contents

#= export ActionCable
#= require_self
#= require ./action_cable/consumer

@ActionCable =
  INTERNAL: <%= ActionCable::INTERNAL.to_json %>
  WebSocket: window.WebSocket
  logger: window.console

  createConsumer: (url) ->
    url ?= @getConfig("url") ? @INTERNAL.default_mount_path
    new ActionCable.Consumer @createWebSocketURL(url)

  getConfig: (name) ->
    element = document.head.querySelector("meta[name='action-cable-#{name}']")
    element?.getAttribute("content")

  createWebSocketURL: (url) ->
    if url and not /^wss?:/i.test(url)
      a = document.createElement("a")
      a.href = url
      # Fix populating Location properties in IE. Otherwise, protocol will be blank.
      a.href = a.href
      a.protocol = a.protocol.replace("http", "ws")
      a.href
    else
      url

  startDebugging: ->
    @debugging = true

  stopDebugging: ->
    @debugging = null

  log: (messages...) ->
    if @debugging
      messages.push(Date.now())
      @logger.log("[ActionCable]", messages...)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby-on-quails-0.1.0 actioncable/app/assets/javascripts/action_cable.coffee.erb