messagepush

package
v0.0.0-...-e9f0680 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2022 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	MsgPort        uint32 `json:"msgPort" yaml:"msgPort"`
	WsReadTimeout  uint32 `json:"wsReadTimeout" yaml:"wsReadTimeout"`
	WsWriteTimeout uint32 `json:"wsWriteTimeout" yaml:"wsWriteTimeout"`
}

func NewConfig

func NewConfig() *Config

func (*Config) RegisterFlagsWithPrefix

func (c *Config) RegisterFlagsWithPrefix(prefix string, f *pflag.FlagSet)

RegisterFlagsWithPrefix is used to register flags

func (*Config) Validate

func (c *Config) Validate() error

type Provider

type Provider interface {
	SendMessage(msgpush.PushMessage) error
	Start(ctx *mbcontext.Context) error
}

func New

func New(log logger.Logger, cfg *Config) Provider

type WsConnection

type WsConnection struct {
	logger.Logger

	ConnId    uint64
	WsSocket  *websocket.Conn
	InChan    chan *msgpush.WsMessage   // 读队列
	OutChan   chan *msgpush.PushMessage // 写队列
	Mutex     sync.Mutex                // 避免重复关闭通道
	IsClosed  bool                      // 是否关闭
	CloseChan chan byte                 // 关闭通知
}

WsConnection 连接对象

func (*WsConnection) ProcLoop

func (wsConn *WsConnection) ProcLoop()

ProcLoop 心跳检测

func (*WsConnection) WsRead

func (wsConn *WsConnection) WsRead() (*msgpush.WsMessage, error)

WsRead ...

func (*WsConnection) WsReadLoop

func (wsConn *WsConnection) WsReadLoop()

WsReadLoop ...

func (*WsConnection) WsWrite

func (wsConn *WsConnection) WsWrite(message msgpush.PushMessage) error

WsWrite ...

func (*WsConnection) WsWriteLoop

func (wsConn *WsConnection) WsWriteLoop()

WsWriteLoop ...

Jump to

Keyboard shortcuts

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