notice

package
v2.1.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2020 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Succeed         = 1
	Failed          = 0
	Unauthenticated = -1
	Forbid          = -2
)

Variables

View Source
var (
	ErrUserNotOnline     = errors.New(`通知错误:用户不在线`)
	ErrMsgTypeNotAccept  = errors.New(`通知错误:不接受这种消息类型`)
	ErrClientIDNotOnline = errors.New(`通知错误:ClientID不在线`)
	ErrForcedExit        = errors.New(`Forced exit`)
)

Functions

func Clear

func Clear()

func CloseClient

func CloseClient(user string, clientID uint) bool

func CloseMessage

func CloseMessage(user string, types ...string)

func Default

func Default() *userNotices

func NewUserNotices

func NewUserNotices(debug bool) *userNotices

func OnClose

func OnClose(fn ...func(user string)) *userNotices

func OnOpen

func OnOpen(fn ...func(user string)) *userNotices

func OpenClient

func OpenClient(user string) uint

func OpenMessage

func OpenMessage(user string, types ...string)

func Recv

func Recv(user string, clientID uint) <-chan *Message

func RecvJSON

func RecvJSON(user string, clientID uint) []byte

func RecvXML

func RecvXML(user string, clientID uint) []byte

func Send

func Send(user string, message *Message) error

func SetDebug

func SetDebug(on bool)

func Stdout

func Stdout(message *Message)

Types

type Control

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

func (*Control) Exited

func (c *Control) Exited() *Control

func (*Control) IsExited

func (c *Control) IsExited() bool

type IsExited

type IsExited interface {
	IsExited() bool
}

type Message

type Message struct {
	ClientID uint        `json:"client_id" xml:"client_id"`
	ID       interface{} `json:"id" xml:"id"`
	Type     string      `json:"type" xml:"type"`
	Title    string      `json:"title" xml:"title"`
	Status   int         `json:"status" xml:"status"`
	Content  interface{} `json:"content" xml:"content"`
	Mode     string      `json:"mode" xml:"mode"` //显示模式:notify/element/modal
	Progress *Progress   `json:"progress" xml:"progress"`
}

func NewMessage

func NewMessage() *Message

func NewMessageWithValue

func NewMessageWithValue(typ string, title string, content interface{}, status ...int) *Message

func (*Message) CalcPercent

func (m *Message) CalcPercent() *Message

func (*Message) SetClientID

func (m *Message) SetClientID(clientID uint) *Message

func (*Message) SetContent

func (m *Message) SetContent(content interface{}) *Message

func (*Message) SetID

func (m *Message) SetID(id interface{}) *Message

func (*Message) SetMode

func (m *Message) SetMode(mode string) *Message

func (*Message) SetProgress

func (m *Message) SetProgress(progress *Progress) *Message

func (*Message) SetProgressValue

func (m *Message) SetProgressValue(finish int64, total int64) *Message

func (*Message) SetStatus

func (m *Message) SetStatus(status int) *Message

func (*Message) SetTitle

func (m *Message) SetTitle(title string) *Message

func (*Message) SetType

func (m *Message) SetType(t string) *Message

type Notice

type Notice struct {
	Types    map[string]bool
	Messages map[uint]chan *Message `json:"-" xml:"-"`
}

func NewNotice

func NewNotice() *Notice

type OnlineUser

type OnlineUser struct {
	Notice  *Notice
	Clients uint
}

func NewOnlineUser

func NewOnlineUser() *OnlineUser

type Progress

type Progress struct {
	Total    int64   `json:"total" xml:"total"`
	Finish   int64   `json:"finish" xml:"finish"`
	Percent  float64 `json:"percent" xml:"percent"`
	Complete bool    `json:"complete" xml:"complete"`
	// contains filtered or unexported fields
}

func NewProgress

func NewProgress() *Progress

func (*Progress) CalcPercent

func (p *Progress) CalcPercent() *Progress

func (*Progress) IsExited

func (p *Progress) IsExited() bool

func (*Progress) SetControl

func (p *Progress) SetControl(control IsExited) *Progress

Jump to

Keyboard shortcuts

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