channel

package
v0.0.0-...-9465167 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithChannelOccupiedListener

func WithChannelOccupiedListener(f ListenerFunc) func(*Channel)

WithChannelOccupiedListener appends the given ListenerFunc into the channelOccupiedListeners list

func WithChannelVacatedListener

func WithChannelVacatedListener(f ListenerFunc) func(*Channel)

WithChannelVacatedListener appends the given ListenerFunc into the channelVacatedListeners list

func WithClientEventListener

func WithClientEventListener(f ClientEventListenerFunc) func(*Channel)

WithClientEventListener appends the given ListenerFunc into the clientEventListeners list

func WithMemberAddedListener

func WithMemberAddedListener(f ListenerFunc) func(*Channel)

WithMemberAddedListener appends the given ListenerFunc into the memberAddedListeners list

func WithMemberRemovedListener

func WithMemberRemovedListener(f ListenerFunc) func(*Channel)

WithMemberRemovedListener appends the given ListenerFunc into the memberRemovedListeners list

Types

type Channel

type Channel struct {
	sync.RWMutex

	ID string
	// contains filtered or unexported fields
}

Channel represents an application channel

func New

func New(channelID string, options ...Option) *Channel

New Create a new Channel

func (*Channel) IsOccupied

func (c *Channel) IsOccupied() bool

IsOccupied Return true if the Channel has at least one subscriber

func (*Channel) IsPresence

func (c *Channel) IsPresence() bool

IsPresence Check if the type of the Channel is presence

func (*Channel) IsPresenceOrPrivate

func (c *Channel) IsPresenceOrPrivate() bool

IsPresenceOrPrivate Check if the type of the Channel is presence or is private

func (*Channel) IsPrivate

func (c *Channel) IsPrivate() bool

IsPrivate Check if the type of the Channel is private

func (*Channel) IsPublic

func (c *Channel) IsPublic() bool

IsPublic Check if the type of the Channel is public

func (*Channel) IsSubscribed

func (c *Channel) IsSubscribed(conn *connection.Connection) bool

IsSubscribed check if the user is subscribed

func (*Channel) Publish

func (c *Channel) Publish(event events.Raw, ignore string) error

Publish messages to all Subscribers skip the ignore connection

func (*Channel) PublishMemberAddedEvent

func (c *Channel) PublishMemberAddedEvent(data string, subscription *subscription.Subscription)

PublishMemberAddedEvent Publish a MemberAddedEvent to all subscriptions

func (*Channel) PublishMemberRemovedEvent

func (c *Channel) PublishMemberRemovedEvent(subscription *subscription.Subscription)

PublishMemberRemovedEvent Publish a MemberRemovedEvent to all subscriptions

func (*Channel) Subscribe

func (c *Channel) Subscribe(conn *connection.Connection, channelData string) error

Subscribe Add a new subscriber to the Channel

func (*Channel) Subscriptions

func (c *Channel) Subscriptions() []*subscription.Subscription

Subscriptions returns a slice of subscriptions

func (*Channel) TotalSubscriptions

func (c *Channel) TotalSubscriptions() int

TotalSubscriptions Get the total of subscribers

func (*Channel) TotalUsers

func (c *Channel) TotalUsers() int

TotalUsers Get the total of users.

func (*Channel) Unsubscribe

func (c *Channel) Unsubscribe(conn *connection.Connection) error

Unsubscribe Remove the subscriber from the Channel It destroy the Channel if the channels does not have any subscribers.

type ClientEventListenerFunc

type ClientEventListenerFunc func(*Channel, *subscription.Subscription, string, interface{})

ClientEventListenerFunc listener for client events

type ListenerFunc

type ListenerFunc func(*Channel, *subscription.Subscription)

ListenerFunc listener function

type Option

type Option func(*Channel)

Option constructor function for Channel

Jump to

Keyboard shortcuts

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