Documentation ¶
Index ¶
Constants ¶
View Source
const RoomBufSize = 128
RoomBufSize is the number of incoming messages to buffer for each topic.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Message ¶
Message gets converted to/from JSON and sent in the body of pubsub messages.
func NewMessage ¶
func (*Message) Apply ¶
func (m *Message) Apply(opts ...MessageOption) error
Apply applies the given options to the config, returning the first error encountered (if any).
func (*Message) WithMessage ¶
type MessageOption ¶
type Room ¶
type Room struct { // Messages is a channel of messages received from other peers in the chat room Messages chan *Message // contains filtered or unexported fields }
Room represents a subscription to a single PubSub topic. Messages can be published to the topic with Room.Publish, and received messages are pushed to the Messages channel.
func JoinRoom ¶
func JoinRoom(ctx context.Context, ps *pubsub.PubSub, selfID peer.ID, roomName string) (*Room, error)
JoinRoom tries to subscribe to the PubSub topic for the room name, returning a Room on success.
func (*Room) PublishMessage ¶
Publish sends a message to the pubsub topic.
Click to show internal directories.
Click to hide internal directories.