微信小程序用 web socket 和 rails 的 Action Cable 通讯

Rails 的 js 代码对 websocket 进行了一些封装,直接用 socket 连到 ws://foo.com/cable 是收不到消息的,要客户端发送一个 "subscribe" 到 websocket 才可以

    wx.connectSocket({
      url: 'ws://admin.zuche.neal.cn:3000/cable',
      header:{
        'content-type': 'application/json'
      method:"GET"
    wx.onSocketOpen(function() {
      let id =  JSON.stringify({channel: "CarChannel", car_id: 1});
      wx.sendSocketMessage({
        data: JSON.stringify
        ({command: "subscribe", identifier: id})