gateway

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAlreadyExist

func IsAlreadyExist(err error) bool

func IsClientClosed

func IsClientClosed(err error) bool

func IsClientNotExist

func IsClientNotExist(err error) bool

func SetMessageReader

func SetMessageReader(s MessageReader)

Types

type Client

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

Client represent a user conn conn

func NewClient

func NewClient(conn conn.Connection, mgr gate.Gateway, handler gate.MessageHandler) *Client

func (*Client) EnqueueMessage

func (c *Client) EnqueueMessage(msg *messages.GlideMessage) error

EnqueueMessage 放入下行消息队列

func (*Client) Exit

func (c *Client) Exit()

Exit 退出客户端

func (*Client) GetInfo

func (c *Client) GetInfo() gate.Info

func (*Client) IsRunning

func (c *Client) IsRunning() bool

func (*Client) Logged

func (c *Client) Logged() bool

func (*Client) Run

func (c *Client) Run()

func (*Client) SetID

func (c *Client) SetID(id gate.ID)

SetID 设置 id 标识及设备标识

type Impl

type Impl struct {
	gate.Gateway
	// contains filtered or unexported fields
}

func NewServer

func NewServer(options *Options) (*Impl, error)

func (*Impl) AddClient

func (c *Impl) AddClient(cs gate.Client)

func (*Impl) EnqueueMessage

func (c *Impl) EnqueueMessage(id gate.ID, msg *messages.GlideMessage) error

EnqueueMessage to the client with the specified uid and device, device: pass 0 express all device.

func (*Impl) ExitClient

func (c *Impl) ExitClient(id gate.ID) error

func (*Impl) IsOnline

func (c *Impl) IsOnline(id gate.ID) bool

func (*Impl) SetClientID

func (c *Impl) SetClientID(oldID, newID gate.ID) error

type MessageReader

type MessageReader interface {

	// Read 阻塞读取, 会阻塞当前协程
	Read(conn conn.Connection) (*messages.GlideMessage, error)

	// ReadCh 返回两个管道, 第一个用于读取内容, 第二个用于发送停止读取, 停止读取时切记要发送停止信号
	ReadCh(conn conn.Connection) (<-chan *readerRes, chan<- interface{})
}

MessageReader 表示一个从连接中(Connection)读取消息的读取者, 可以用于定义如何从连接中读取并解析消息.

type Options

type Options struct {
	MaxMessageConcurrency int
}

Jump to

Keyboard shortcuts

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