1.2.5 • Published 9 months ago

@xpomelox/gusher v1.2.5

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

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
  }
}
1.2.5

9 months ago

1.2.4

9 months ago

1.2.3

11 months ago

1.2.0

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago