4 Star 5 Fork 4

Plato/Service-Box-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
defs.go 1.85 KB
一键复制 编辑 原始数据 按行查看 历史
package net
import "net"
const (
StatusIdle = iota
StatusRunning
StatusShutdown
StatusStopped
)
// NetEventQueue event channel type
type NetEventQueue chan *EventData
// IBoxConn box net connection wrapper !
type IBoxConn interface {
// LocalAddr is the connection's local socket address.
LocalAddr() (addr net.Addr)
// RemoteAddr is the connection's remote peer address.
RemoteAddr() (addr net.Addr)
// Read reads data from the connection.
Read(b []byte) (n int, err error)
// Write writes one byte slice to peer asynchronously, usually you would call it in individual goroutines
Write(buf []byte) error
// Close closes the current connection.
Close() error
// IsClose will return ture if connection has been closed
IsClose() bool
OnClose()
}
// IBoxConnector connector wrapper
type IBoxConnector interface {
//Start connector logic
Start() error
//ConnectTo connect to address
ConnectTo(network, address string) (IBoxConn, error)
//Stop all connect
Stop() error
}
// IBoxNetLoop box network loop
type IBoxNetLoop interface {
//Start create network loop
Start() error
//Shutdown will set closed all connections and refuse new connections, it will not stop network loop
Shutdown() error
//Stop all network loop
Stop() error
//Tick network goroutine tick func
Tick()
//Notify logic goroutine net event
Notify(data *EventData)
//SendToLoop send event to network goroutine, deal by tick function
SendToLoop(data *EventData)
//ConnectTo connect to remote server
ConnectTo(network, address string) (IBoxConn, error)
//ListenAt listen at address
ListenAt(network, address string) error
}
// BoxConn create new box conn, param: gnet.Conn
var BoxConn = makeGnetConn
// BoxConnector client connector, param: serverEH
var BoxConnector = makeConnector
// BoxLoop box network loop, listen or connect, param: NetEventQueue
var BoxLoop = makeGnetLoop
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/dennis-kk/service-box-go.git
git@gitee.com:dennis-kk/service-box-go.git
dennis-kk
service-box-go
Service-Box-go
v0.5.14

搜索帮助