Documentation
¶
Index ¶
- Constants
- func BuildInvalidRet(desc string) string
- func ChannelTypeStr(channelType int) string
- func GetCurrentChannelType() int
- func InitChannelMgr(CallBack OnReceiveMsg) error
- func OnNetworkRecover()
- func OnRecvMsg(Msg string, ChannelType int) string
- func StartChannelMgr()
- func TryStartGshellChannel()
- type Channel
- type ChannelMgr
- type GshellChannel
- type GshellCheck
- type GshellCheckReply
- type GshellCmd
- type GshellCmdReply
- type GshellInvalid
- type GshellShutdown
- type IChannel
- type NetcheckReply
- type OnReceiveMsg
- type WebSocketChannel
- func (c *WebSocketChannel) IsSupported() bool
- func (c *WebSocketChannel) ResetFailedCount()
- func (c *WebSocketChannel) StartChannel() error
- func (c *WebSocketChannel) StartPings(pingInterval time.Duration)
- func (c *WebSocketChannel) StopChannel() error
- func (c *WebSocketChannel) SwitchChannel() error
Constants ¶
View Source
const ( ChannelNone = 0 ChannelGshellType = 1 ChannelWebsocketType = 2 )
View Source
const ( WEBSOCKET_SERVER = "/luban/notify_server" MAX_RETRY_COUNT = 5 )
Variables ¶
This section is empty.
Functions ¶
func BuildInvalidRet ¶
func ChannelTypeStr ¶
func GetCurrentChannelType ¶
func GetCurrentChannelType() int
func InitChannelMgr ¶
func InitChannelMgr(CallBack OnReceiveMsg) error
func OnNetworkRecover ¶
func OnNetworkRecover()
OnNetworkRecover will be called when network recover
func StartChannelMgr ¶
func StartChannelMgr()
func TryStartGshellChannel ¶
func TryStartGshellChannel()
Types ¶
type Channel ¶
type Channel struct { CallBack OnReceiveMsg ChannelType int Working atomicutil.AtomicBoolean }
func (*Channel) GetChannelType ¶
type ChannelMgr ¶
type ChannelMgr struct { ActiveChannel IChannel //current used channel AllChannel []IChannel //the first one is GshellChannel StopChanelEvent chan struct{} WaitCheckDone sync.WaitGroup ChannelSetLock sync.Mutex }
manage all channels
var G_ChannelMgr *ChannelMgr = &ChannelMgr{ StopChanelEvent: make(chan struct{}), }
new
func (*ChannelMgr) GetCurrentChannelType ¶
func (m *ChannelMgr) GetCurrentChannelType() int
func (*ChannelMgr) Init ¶
func (m *ChannelMgr) Init(CallBack OnReceiveMsg) error
func (*ChannelMgr) SelectAvailableChannel ¶
func (m *ChannelMgr) SelectAvailableChannel(currentChannel int) error
func (*ChannelMgr) SelectAvailableChannelAndReport ¶
func (m *ChannelMgr) SelectAvailableChannelAndReport(currentChannel int, reason string, ignoreFailed bool) error
SelectAvailableChannelAndReport will call SelectAvailableChannel and report the result, but the failure will not be reported if ignoreFailed is true.
type GshellChannel ¶
type GshellChannel struct { *Channel WaitCheckDone sync.WaitGroup // contains filtered or unexported fields }
func (*GshellChannel) IsSupported ¶
func (c *GshellChannel) IsSupported() bool
func (*GshellChannel) StartChannel ¶
func (c *GshellChannel) StartChannel() error
func (*GshellChannel) StopChannel ¶
func (c *GshellChannel) StopChannel() error
func (*GshellChannel) SwitchChannel ¶
func (c *GshellChannel) SwitchChannel() error
type GshellCheck ¶
type GshellCheckReply ¶
type GshellCheckReply struct {
Return int64 `json:"return"`
}
type GshellCmdReply ¶
type GshellCmdReply struct { Return struct { CmdOutput string `json:"cmd_output"` // netcheck field would not presented when no diagnostic result available Netcheck *NetcheckReply `json:"netcheck,omitempty"` Result int `json:"result"` } `json:"return"` }
type GshellInvalid ¶
type GshellShutdown ¶
type IChannel ¶
type IChannel interface { //Is current channel working IsWorking() bool //Is current channel supported IsSupported() bool //Get Channel Type GetChannelType() int //Start channel StartChannel() error //Stop channel StopChannel() error }
Abstract base class for channel
func NewGshellChannel ¶
func NewGshellChannel(CallBack OnReceiveMsg) IChannel
type NetcheckReply ¶
NetcheckReply represents
func LastNetcheckReply ¶
func LastNetcheckReply() *NetcheckReply
type OnReceiveMsg ¶
type WebSocketChannel ¶
type WebSocketChannel struct { *Channel // contains filtered or unexported fields }
func NewWebsocketChannel ¶
func NewWebsocketChannel(CallBack OnReceiveMsg) *WebSocketChannel
func (*WebSocketChannel) IsSupported ¶
func (c *WebSocketChannel) IsSupported() bool
func (*WebSocketChannel) ResetFailedCount ¶
func (c *WebSocketChannel) ResetFailedCount()
func (*WebSocketChannel) StartChannel ¶
func (c *WebSocketChannel) StartChannel() error
func (*WebSocketChannel) StartPings ¶
func (c *WebSocketChannel) StartPings(pingInterval time.Duration)
func (*WebSocketChannel) StopChannel ¶
func (c *WebSocketChannel) StopChannel() error
func (*WebSocketChannel) SwitchChannel ¶
func (c *WebSocketChannel) SwitchChannel() error
Click to show internal directories.
Click to hide internal directories.