Documentation ¶
Index ¶
- Constants
- Variables
- func Clear()
- func CloseClient(user string, clientID uint32) bool
- func CloseMessage(user string, types ...string)
- func Default() *userNotices
- func NewUserNotices(debug bool) *userNotices
- func OnClose(fn ...func(user string)) *userNotices
- func OnOpen(fn ...func(user string)) *userNotices
- func OpenClient(user string) uint32
- func OpenMessage(user string, types ...string)
- func Recv(user string, clientID uint32) <-chan *Message
- func RecvJSON(user string, clientID uint32) []byte
- func RecvXML(user string, clientID uint32) []byte
- func Send(user string, message *Message) error
- func SetDebug(on bool)
- func Stdout(message *Message)
- type Control
- type HTTPNoticerConfig
- type IsExited
- type Message
- func (m *Message) CalcPercent() *Message
- func (m *Message) SetClientID(clientID uint32) *Message
- func (m *Message) SetContent(content interface{}) *Message
- func (m *Message) SetID(id interface{}) *Message
- func (m *Message) SetMode(mode string) *Message
- func (m *Message) SetProgress(progress *Progress) *Message
- func (m *Message) SetProgressValue(finish int64, total int64) *Message
- func (m *Message) SetStatus(status int) *Message
- func (m *Message) SetTitle(title string) *Message
- func (m *Message) SetType(t string) *Message
- type Notice
- type Noticer
- type OnlineUser
- type Progress
Constants ¶
View Source
const ( Succeed = 1 Failed = 0 Unauthenticated = -1 Forbid = -2 )
Variables ¶
Functions ¶
func CloseClient ¶
func CloseMessage ¶
func NewUserNotices ¶
func NewUserNotices(debug bool) *userNotices
func OpenClient ¶
func OpenMessage ¶
Types ¶
type HTTPNoticerConfig ¶
type Message ¶
type Message struct { ClientID uint32 `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 (*Message) CalcPercent ¶
func (*Message) SetClientID ¶
func (*Message) SetContent ¶
func (*Message) SetProgress ¶
func (*Message) SetProgressValue ¶
type Noticer ¶
var ( // DefaultNoticer 默认noticer // statusCode > 0 为成功;否则为失败 DefaultNoticer Noticer = func(message interface{}, statusCode int, progs ...*Progress) error { if len(progs) > 0 && progs[0] != nil { message = `[ ` + tplfunc.NumberFormat(progs[0].CalcPercent().Percent, 2) + `% ] ` + fmt.Sprint(message) } if statusCode > 0 { log.Info(message) } else { log.Error(message) } return nil } CustomOutputNoticer func(wOut io.Writer, wErr io.Writer) Noticer = func(wOut io.Writer, wErr io.Writer) Noticer { return func(message interface{}, statusCode int, progs ...*Progress) error { if len(progs) > 0 && progs[0] != nil { message = `[ ` + tplfunc.NumberFormat(progs[0].CalcPercent().Percent, 2) + `% ] ` + fmt.Sprint(message) } if statusCode > 0 { fmt.Fprintln(wOut, message) } else { fmt.Fprintln(wErr, message) } return nil } } )
func NewNoticer ¶
func NewNoticer(ctx context.Context, config *HTTPNoticerConfig) Noticer
type OnlineUser ¶
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 (*Progress) SetControl ¶
Click to show internal directories.
Click to hide internal directories.