handle

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientBroadcastEvent added in v0.1.0

func ClientBroadcastEvent(trigger *Handler, targets []interface{}, uuid string, data string)

func ClientBroadcastEventCallback added in v0.1.0

func ClientBroadcastEventCallback(trigger *Handler, target interface{}, uuid string, data string)

func ClientOnlineStatusChangeEvent added in v0.1.0

func ClientOnlineStatusChangeEvent(trigger *Handler, online bool)

func CreateNTQQWebSocket

func CreateNTQQWebSocket() error

func CreateWSInstance

func CreateWSInstance(port int)

CreateWSInstance create new ws instance and wait client connection

func EnableHttpService added in v0.1.0

func EnableHttpService(port int)

EnableHttpService enable http server

func GetOnlineClients added in v0.1.0

func GetOnlineClients(ctx *gin.Context)

GetOnlineClients get online clients array

func GetWebSocketPort added in v0.1.0

func GetWebSocketPort(ctx *gin.Context)

GetWebSocketPort get available ws port

func Init

func Init()

func TryReverseWSInstance added in v0.2.0

func TryReverseWSInstance(wsUrl string, accessToken string) error

TryReverseWSInstance try to establish reverse ws client connection

func TryTouchEnhanceHook added in v0.1.0

func TryTouchEnhanceHook(msgData global.MsgData, handler *Handler) (global.MsgData, bool, error)

TryTouchEnhanceHook check and handle api if exists @return data, exist, error

Types

type Cache

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

func NewCache

func NewCache(expireTime time.Duration) *Cache

func (*Cache) Append

func (c *Cache) Append(data global.MsgData) (string, error)

type EchoMap

type EchoMap struct {
	Receive chan bool
	// contains filtered or unexported fields
}

EchoMap 利用 echo 完成 NTQQ -> client 消息调度 (发送时标记echo)

func NewEchoMap

func NewEchoMap() *EchoMap

func (*EchoMap) JustGet

func (em *EchoMap) JustGet(id string, consumer func(global.MsgData))

func (*EchoMap) JustPut

func (em *EchoMap) JustPut(id string, data global.MsgData)

JustPut echo

type Handler

type Handler struct {
	Receive chan bool
	Lock    sync.Mutex
	// contains filtered or unexported fields
}

func FindHandler

func FindHandler(id string) *Handler

func NewHandler

func NewHandler(ctx context.Context) *Handler

func (*Handler) AddMessage

func (h *Handler) AddMessage(uuid string)

func (*Handler) AddWait

func (h *Handler) AddWait()

AddWait 添加任务协程数

func (*Handler) GetId

func (h *Handler) GetId() string

func (*Handler) GetMessage

func (h *Handler) GetMessage(consumer func(data global.MsgData))

GetMessage from local cache

func (*Handler) GetName added in v0.1.0

func (h *Handler) GetName() string

func (*Handler) ShouldExit

func (h *Handler) ShouldExit() bool

ShouldExit 是否需要结束

func (*Handler) WaitDone

func (h *Handler) WaitDone()

WaitDone 等待任务结束

func (*Handler) WaitExitAll

func (h *Handler) WaitExitAll()

WaitExitAll 结束所有等待

Jump to

Keyboard shortcuts

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