Documentation ¶
Index ¶
- func RegisterPrivateChannel(channelStr string) channel.Channel
- func RegisterPrivateChannels(channels ...string) []channel.Channel
- func RegisterPublicChannel(channelStr string) channel.Channel
- func RegisterPublicChannels(channels ...string) []channel.Channel
- func WithAuthFunc(authFunc auth.AuthenticateFunc) func(config *Config)
- func WithLogger(logger log.Logger) func(config *Config)
- func WithOutboundBufferSize(size int) conn.Option
- func WithPingMessageFunc(messageFunc conn.PingMessageFunc) conn.Option
- func WithPingPeriod(duration time.Duration) conn.Option
- func WithPongWait(duration time.Duration) conn.Option
- type Channelize
- func (c *Channelize) CreateConnection(ctx context.Context, wsConn *websocket.Conn, options ...conn.Option) *conn.Connection
- func (c *Channelize) MakeHTTPHandler(appCtx context.Context, upgrader websocket.Upgrader, options ...conn.Option) http.HandlerFunc
- func (c *Channelize) SendPrivateMessage(ctx context.Context, ch channel.Channel, userID string, message interface{}) error
- func (c *Channelize) SendPublicMessage(ctx context.Context, ch channel.Channel, message interface{}) error
- type Config
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterPrivateChannel ¶
RegisterPrivateChannel creates and registers a new channel by calling the internal channel.RegisterPrivateChannel function. It returns the created channel.
func RegisterPrivateChannels ¶
RegisterPrivateChannels creates and registers a list of input channels by calling the internal channel.RegisterPrivateChannels function. It returns a list of created channels.
func RegisterPublicChannel ¶
RegisterPublicChannel creates and registers a new channel by calling the internal channel.RegisterPublicChannel function. It returns the created channel.
func RegisterPublicChannels ¶
RegisterPublicChannels creates and registers a list of input channels by calling the internal channel.RegisterPublicChannels function. It returns a list of created channels.
func WithAuthFunc ¶
func WithAuthFunc(authFunc auth.AuthenticateFunc) func(config *Config)
func WithLogger ¶
func WithOutboundBufferSize ¶
WithOutboundBufferSize sets the outbound buffer size.
func WithPingMessageFunc ¶
func WithPingMessageFunc(messageFunc conn.PingMessageFunc) conn.Option
WithPingMessageFunc sets the ping function. Client send customized ping messages.
func WithPingPeriod ¶
WithPingPeriod sets the ping period.
Types ¶
type Channelize ¶
type Channelize struct {
// contains filtered or unexported fields
}
Channelize wraps all the internal implementations and restricts the exposed functionalities to reduce the public API surface.
It provides more APIs like HTTP handlers to facilitate the API usage.
func NewChannelize ¶
func NewChannelize(options ...Option) *Channelize
NewChannelize creates new instance of Channelize struct. It uses in-memory storage by default to store the connections and mapping between the connections and channels.
func (*Channelize) CreateConnection ¶
func (c *Channelize) CreateConnection(ctx context.Context, wsConn *websocket.Conn, options ...conn.Option) *conn.Connection
CreateConnection creates a `conn.Connection` object with the input options.
func (*Channelize) MakeHTTPHandler ¶
func (c *Channelize) MakeHTTPHandler(appCtx context.Context, upgrader websocket.Upgrader, options ...conn.Option) http.HandlerFunc
MakeHTTPHandler makes a built-in HTTP handler function. The client should provide the websocket.Upgrader. It automatically creates the websocket.Conn and conn.Connection.
func (*Channelize) SendPrivateMessage ¶
func (c *Channelize) SendPrivateMessage(ctx context.Context, ch channel.Channel, userID string, message interface{}) error
SendPrivateMessage sends the message to the input channel.
func (*Channelize) SendPublicMessage ¶
func (c *Channelize) SendPublicMessage(ctx context.Context, ch channel.Channel, message interface{}) error
SendPublicMessage sends the message to the input channel.