How to use the actioncable.createWebSocketURL function in actioncable

To help you get started, we’ve selected a few actioncable examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cpunion / react-native-actioncable / index.js View on Github external
import React, { Component, PropTypes } from 'react'
import { Platform } from 'react-native';
import ActionCable from 'actioncable'

ActionCable.getConfig = () => null
ActionCable.createWebSocketURL = (url) => url.replace(/^http/, 'ws')

const oldOpen = ActionCable.Connection.prototype.open
ActionCable.Connection.prototype.open = function () {
  const result = oldOpen.apply(this)
  this.webSocket.protocol = 'actioncable-v1-json'
  return result
}

if(Platform.OS == 'ios' || Platform.OS == 'android'){
  global.document = {
    addEventListener () {},
    removeEventListener () {}
  }
}

export default ActionCable

actioncable

WebSocket framework for Ruby on Rails.

MIT
Latest version published 2 years ago

Package Health Score

78 / 100
Full package analysis