Skip to content

Latest commit

 

History

History
61 lines (43 loc) · 1.18 KB

File metadata and controls

61 lines (43 loc) · 1.18 KB

Channels

With channel method you're able to:

  • Publish messages to realtime channels

Import

const {channel} = new Server(ctx)

Methods

Name Description
channel.publish Publish message to channel

channel.publish(channel, payload?)

Type Name Default Description
string channel null Name of the channel
object payload null Additional data passed to channel

Publishing to public channel

endpoints:
  messages:
    channel: messages
channel.publish('messages', {content: 'hello'})

Publishing to channel room

endpoints:
  messages:
    channel: messages.{room}
channel.publish(`messages.${room}`, {content: 'hello'})

Publishing to user private channel

endpoints:
  messages:
    channel: messages.{user}
channel.publish(`messages.${username}`, {content: 'hello'})