channels

package
v1.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel

type Channel struct {

	// Private channel instance.
	Private *PrivateChannel

	// Presence channel instance.
	Presence *PresenceChannel
	// contains filtered or unexported fields
}

func NewChannel

func NewChannel(io *socket.Server, _options *options.Config) (ch *Channel, err error)

Create a new channel instance.

func (*Channel) ClientEvent

func (ch *Channel) ClientEvent(_socket *socket.Socket, data *types.Data)

Trigger a client message

func (*Channel) IsClientEvent

func (ch *Channel) IsClientEvent(event string) bool

Check if client is a client event

func (*Channel) IsInChannel

func (ch *Channel) IsInChannel(_socket *socket.Socket, channel string) bool

Check if a socket has joined a channel.

func (*Channel) IsPresence

func (ch *Channel) IsPresence(channel string) bool

Check if a channel is a presence channel.

func (*Channel) IsPrivate

func (ch *Channel) IsPrivate(channel string) bool

Check if the incoming socket connection is a private channel.

func (*Channel) Join

func (ch *Channel) Join(_socket *socket.Socket, data *types.Data)

Join a channel.

func (*Channel) JoinPrivate

func (ch *Channel) JoinPrivate(_socket *socket.Socket, data *types.Data)

Join private channel, emit data to presence channels.

func (*Channel) Leave

func (ch *Channel) Leave(_socket *socket.Socket, channel string, reason string)

Leave a channel.

func (*Channel) OnJoin

func (ch *Channel) OnJoin(_socket *socket.Socket, channel string)

On join a channel log success.

type PresenceChannel

type PresenceChannel struct {
	// contains filtered or unexported fields
}

func NewPresenceChannel

func NewPresenceChannel(io *socket.Server, _options *options.Config) (pch *PresenceChannel, err error)

Create a NewPresence channel instance.

func (*PresenceChannel) Close added in v1.1.0

func (pch *PresenceChannel) Close() error

func (*PresenceChannel) GetMembers

func (pch *PresenceChannel) GetMembers(channel string) (members types.Members, _ error)

Get the members of a presence channel.

func (*PresenceChannel) IsMember

func (pch *PresenceChannel) IsMember(channel string, member *types.Member) (bool, error)

Check if a user is on a presence channel.

func (*PresenceChannel) Join

func (pch *PresenceChannel) Join(socket *socket.Socket, channel string, member *types.Member) error

Join a presence channel and emit that they have joined only if it is the first instance of their presence.

func (*PresenceChannel) Leave

func (pch *PresenceChannel) Leave(socket *socket.Socket, channel string) error

Remove a member from a presenece channel and broadcast they have left only if not other presence channel instances exist.

func (*PresenceChannel) OnJoin

func (pch *PresenceChannel) OnJoin(_socket *socket.Socket, channel string, member *types.Member)

On join event handler.

func (*PresenceChannel) OnLeave

func (pch *PresenceChannel) OnLeave(channel string, member *types.Member)

On Leave emitter.

func (*PresenceChannel) OnSubscribed

func (pch *PresenceChannel) OnSubscribed(_socket *socket.Socket, channel string, members types.Members)

On subscribed event emitter.

func (*PresenceChannel) RemoveInactive

func (pch *PresenceChannel) RemoveInactive(channel string, members types.Members, member *types.Member) (_members types.Members, _ error)

Remove inactive channel members from the presence channel.

type PrivateChannel

type PrivateChannel struct {
	// contains filtered or unexported fields
}

func NewPrivateChannel

func NewPrivateChannel(_options *options.Config) *PrivateChannel

Create a new private channel instance.

func (*PrivateChannel) Authenticate

func (pch *PrivateChannel) Authenticate(_socket *socket.Socket, data *types.Data) (any, int, error)

Send authentication request to application server.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL