util

package
v0.0.0-...-f0a9cfb Latest Latest
Warning

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

Go to latest
Published: May 27, 2023 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

View Source
const (
	SuccessCode int = 0
	ErrorCode   int = -1
)

Variables

This section is empty.

Functions

func BroadcastFilterJson

func BroadcastFilterJson(msg interface{}, fn func(*melody.Session) bool) error

BroadcastFilterJson broadcasts a text message to all sessions that fn returns true for.

func BroadcastJson

func BroadcastJson(bizType string, msg string, data interface{}) error

BroadcastJson Broadcast broadcasts a text message to all sessions.

func BroadcastMultipleJson

func BroadcastMultipleJson(sessions []*melody.Session, bizType string, msg string, data interface{}) error

BroadcastMultipleJson broadcasts a text message to multiple sessions given in the sessions slice.

func BroadcastOthersJson

func BroadcastOthersJson(s *melody.Session, bizType string, msg string, data interface{}) error

BroadcastOthersJson BroadcastOthers broadcasts a text message to all sessions except session s.

func WriteFailJson

func WriteFailJson(s *melody.Session, bizType string, msg string, data ...interface{}) error

func WriteFailJsonExit

func WriteFailJsonExit(s *melody.Session, bizType string, msg string, data ...interface{}) error

func WriteJson

func WriteJson(s *melody.Session, bizType string, code int, msg string, data ...interface{}) error

func WriteJsonExit

func WriteJsonExit(s *melody.Session, bizType string, code int, msg string, data ...interface{}) error

func WriteSusJson

func WriteSusJson(s *melody.Session, bizType string, msg string, data ...interface{}) error

func WriteSusJsonExit

func WriteSusJsonExit(s *melody.Session, bizType string, msg string, data ...interface{}) error

Types

type SecondsTimer

type SecondsTimer struct {
	Timer *time.Timer
	End   time.Time
}

func NewSecondsTimer

func NewSecondsTimer(t time.Duration) *SecondsTimer

func (*SecondsTimer) Reset

func (s *SecondsTimer) Reset(t time.Duration)

func (*SecondsTimer) Stop

func (s *SecondsTimer) Stop()

func (*SecondsTimer) TimeRemaining

func (s *SecondsTimer) TimeRemaining() time.Duration

type ServerMsg

type ServerMsg struct {
	BizType string `json:"biz_type"` //业务消息类型
	// 代码
	Code int `json:"code" example:"200"`
	// 数据集
	Data interface{} `json:"data"`
	// 消息
	Msg string `json:"message"`
}

Jump to

Keyboard shortcuts

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