channel

package
v0.0.0-...-028f1de Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

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 BuildInvalidRet(desc string) string

func ChannelTypeStr

func ChannelTypeStr(channelType int) string

func GetCurrentChannelType

func GetCurrentChannelType() int

func InitChannelMgr

func InitChannelMgr(CallBack OnReceiveMsg) error

func OnRecvMsg

func OnRecvMsg(Msg string, ChannelType int) string

func StartChannelMgr

func StartChannelMgr()

func StopChannelMgr

func StopChannelMgr() error

func TryStartGshellChannel

func TryStartGshellChannel()

Types

type Channel

type Channel struct {
	CallBack    OnReceiveMsg
	ChannelType int
	Working     atomicutil.AtomicBoolean
}

func (*Channel) GetChannelType

func (c *Channel) GetChannelType() int

func (*Channel) IsWorking

func (c *Channel) IsWorking() bool

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) Uninit

func (m *ChannelMgr) Uninit()

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 GshellCheck struct {
	Execute   string `json:"execute"`
	Arguments struct {
		ID int64 `json:"id"`
	} `json:"arguments"`
}

type GshellCheckReply

type GshellCheckReply struct {
	Return int64 `json:"return"`
}

type GshellCmd

type GshellCmd struct {
	Execute   string `json:"execute"`
	Arguments struct {
		Cmd string `json:"cmd"`
	} `json:"arguments"`
}

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 GshellInvalid struct {
	Error struct {
		Class string `json:"class"`
		Desc  string `json:"desc"`
	} `json:"error"`
}

type GshellShutdown

type GshellShutdown struct {
	Execute   string `json:"execute"`
	Arguments struct {
		Mode string `json:"mode"`
	} `json:"arguments"`
}

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

func NewWebsocketChannel

func NewWebsocketChannel(CallBack OnReceiveMsg) IChannel

type NetcheckReply

type NetcheckReply struct {
	Result    int   `json:"result"`
	Timestamp int64 `json:"timestamp"`
}

NetcheckReply represents

func LastNetcheckReply

func LastNetcheckReply() *NetcheckReply

type OnReceiveMsg

type OnReceiveMsg func(Msg string, ChannelType int) string

type WebSocketChannel

type WebSocketChannel struct {
	*Channel
	// contains filtered or unexported fields
}

func (*WebSocketChannel) IsSupported

func (c *WebSocketChannel) IsSupported() bool

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

Jump to

Keyboard shortcuts

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