gusher.cluster client


Keywords
gusher
License
MIT
Install
npm install gusher-js@0.3.0

Documentation

gusher-js

gusher.cluster 是一套參考Pusher設計概念,透過golang開發 WebSocket Server。

應用 channel 以及 event 設計,可以按自己想要的方式訂閱頻道接收對應的事件訊息,

Install with:

npm install gusher-js

Usage

const gusher = new Gusher('app_name', {
    url: 'ws_url',
    token: 'auth_token'
})

gusher.connect()

const channel = gusher.subscribe('channel')

channel.bind('event', (data) => {
  console.log('Received from channel:', data)
})

補充說明

gusher.cluster的認證方式,在文檔上沒有標注說明,其auth機制依賴Redis保存,通常會由另外的認證服務完成檢查後產生身分憑證使用的token,將其資訊記錄在RedisDB上。

結構大致如下,可以根據需求定置好頻道的類型,例如是個人資訊的私有頻道或是特定公開資料的共同頻道或是群組共用的群組頻道等…

{
  "channels": ["dev"],
  "user_id": "123456",
  "app_key": "app",
  "remotes": {
    "test": true
  }
}