0.3.5 • Published 2 years ago

@aronative/nexchat v0.3.5

Weekly downloads
-
License
GPL-3.0-or-later
Repository
-
Last release
2 years ago

NexChat Pusher Library

Installation

Install using yarn package manager

yarn add @aronative/nexchat

or install using npm

npm i @aronative/nexchat

or include in html (Pusher module only)

<script src="https://nexchat.ir/apps/NextPusher.umd.min.js?token=$API_KEY"></script>

Usage

Connect to websocket server

Provide <API_KEY> only if api key is not provided in include script tag.

const nextPusher = new NextPusher(/*<API_KEY: Optional>*/)
nextPusher.connect()

Connect to public broadcast channel for everyone

nextPusher.listenBroadcast(res => {
    console.log('message > ' + res.message)
})

Connect ro private broadcast channel for all users

nextPusher.listenWhisper(res => {
    console.log('message > ' + res.message)
})

Connect to Public room with identification id

Replace ROOM_ID with your room id

nextPusher.listenRoom(ROOM_ID, res => {
    console.log('message > ' + res.message)
})

Private channel with identification id

Replace CHANNEL_ID with your channel id

nextPusher.listenChannel(CHANNEL_ID, res => {
    console.log('message > ' + res.message)
})

Disconnect from Server

nextPusher.disconnect()

Publish

yarn publish --registry=https://registry.npmjs.org