Documentation
¶
Index ¶
- type Builder
- type Client
- func (c *Client) Bind(ctx context.Context, cid, uid int64) error
- func (c *Client) Broadcast(ctx context.Context, kind session.Kind, disconnect bool, buf buffer.Buffer, ...) (int64, error)
- func (c *Client) Disconnect(ctx context.Context, kind session.Kind, target int64, force bool) error
- func (c *Client) GetIP(ctx context.Context, kind session.Kind, target int64) (string, error)
- func (c *Client) GetState(ctx context.Context) (cluster.State, error)
- func (c *Client) IsOnline(ctx context.Context, kind session.Kind, target int64) (bool, error)
- func (c *Client) Multicast(ctx context.Context, kind session.Kind, targets []int64, disconnect bool, ...) (int64, error)
- func (c *Client) Publish(ctx context.Context, channel string, disconnect bool, buf buffer.Buffer, ...) (int64, error)
- func (c *Client) Push(ctx context.Context, kind session.Kind, target int64, disconnect bool, ...) error
- func (c *Client) SetState(ctx context.Context, state cluster.State) error
- func (c *Client) Stat(ctx context.Context, kind session.Kind) (int64, error)
- func (c *Client) Subscribe(ctx context.Context, kind session.Kind, targets []int64, channel string) error
- func (c *Client) Unbind(ctx context.Context, uid int64) error
- func (c *Client) Unsubscribe(ctx context.Context, kind session.Kind, targets []int64, channel string) error
- type ClientOptions
- type Provider
- type Server
- type ServerOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
func NewBuilder ¶
func NewBuilder(opts *ClientOptions) *Builder
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) Broadcast ¶
func (c *Client) Broadcast(ctx context.Context, kind session.Kind, disconnect bool, buf buffer.Buffer, ack bool) (int64, error)
Broadcast pushes a message to all sessions. When ack is true it waits for the response and returns the number of sessions that received the message.
func (*Client) Disconnect ¶
Disconnect disconnects the target session.
func (*Client) Multicast ¶
func (c *Client) Multicast(ctx context.Context, kind session.Kind, targets []int64, disconnect bool, buf buffer.Buffer, ack bool) (int64, error)
Multicast pushes a message to multiple targets. When ack is true it waits for the response and returns the number of targets that received the message.
func (*Client) Publish ¶ added in v2.3.0
func (c *Client) Publish(ctx context.Context, channel string, disconnect bool, buf buffer.Buffer, ack bool) (int64, error)
Publish publishes a message to a channel. When ack is true it waits for the response and returns the number of sessions that received the message.
func (*Client) Push ¶
func (c *Client) Push(ctx context.Context, kind session.Kind, target int64, disconnect bool, buf buffer.Buffer, ack bool) error
Push pushes a message to the target. When ack is true it waits for the response.
func (*Client) Subscribe ¶ added in v2.3.0
func (c *Client) Subscribe(ctx context.Context, kind session.Kind, targets []int64, channel string) error
Subscribe subscribes the targets to a channel.
type ClientOptions ¶ added in v2.5.4
type ClientOptions = drpc.ClientOptions
type Provider ¶
type Provider interface {
// Bind binds the relationship between the user and the gate.
Bind(ctx context.Context, cid, uid int64) error
// Unbind unbinds the relationship between the user and the gate.
Unbind(ctx context.Context, uid int64) error
// GetIP returns the client IP address.
GetIP(ctx context.Context, kind session.Kind, target int64) (ip string, err error)
// IsOnline reports whether the target is online.
IsOnline(ctx context.Context, kind session.Kind, target int64) (isOnline bool, err error)
// Stat returns the total number of sessions.
Stat(ctx context.Context, kind session.Kind) (total int64, err error)
// Disconnect disconnects the target session.
Disconnect(ctx context.Context, kind session.Kind, target int64, force bool) error
// Push sends a message.
Push(ctx context.Context, kind session.Kind, target int64, disconnect bool, buf buffer.Buffer) error
// Multicast pushes a multicast message.
Multicast(ctx context.Context, kind session.Kind, targets []int64, disconnect bool, buf buffer.Buffer) (total int64, err error)
// Broadcast pushes a broadcast message.
Broadcast(ctx context.Context, kind session.Kind, disconnect bool, buf buffer.Buffer) (total int64, err error)
// Publish publishes a channel message.
Publish(ctx context.Context, channel string, disconnect bool, buf buffer.Buffer) (total int64, err error)
// Subscribe subscribes to channels.
Subscribe(ctx context.Context, kind session.Kind, targets []int64, channel string) error
// Unsubscribe unsubscribes from channels.
Unsubscribe(ctx context.Context, kind session.Kind, targets []int64, channel string) error
// GetState returns the state.
GetState() (cluster.State, error)
// SetState sets the state.
SetState(state cluster.State) error
}
type ServerOptions ¶ added in v2.3.0
type ServerOptions = drpc.ServerOptions
Click to show internal directories.
Click to hide internal directories.