Documentation ¶
Index ¶
Constants ¶
View Source
const ( BoxConnClose = iota BoxConnConnecting )
View Source
const ( StatusIdle = iota StatusRunning StatusShutdown StatusStopped )
View Source
const ( EventAccept = iota //accept net connected from peer EventReqConnect //request for connecting to remote EventRespConnect //connect to remote successfully EventReceive //receive Data EventClose //Conn has been closed EventShutdown //server shut down ! EventMaxFlag //network event end )
Variables ¶
View Source
var BoxConn = makeGnetConn
BoxConn create new box conn, param: gnet.Conn
View Source
var BoxConnector = makeConnector
BoxConnector client connector, param: serverEH
View Source
var BoxLoop = makeGnetLoop
BoxLoop box network loop, listen or connect, param: NetEventQueue
Functions ¶
This section is empty.
Types ¶
type AcceptEvent ¶
AcceptEvent accept or connect
type ClosedEvent ¶
type ClosedEvent struct {
TSid string //Conn handle address
}
ClosedEvent conn has been closed by network framework
type ConnectEvent ¶
ConnectEvent connect successfully
type ConnectToEvent ¶
type EventData ¶
type IBoxConn ¶
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() }
IBoxConn box net connection wrapper !
type IBoxConnector ¶
type IBoxConnector interface { //Start connector logic Start() error //ConnectTo connect to address ConnectTo(network, address string) (IBoxConn, error) //Stop all connect Stop() error }
IBoxConnector connector wrapper
type IBoxNetLoop ¶
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 }
IBoxNetLoop box network loop
type ReceiveEvent ¶
ReceiveEvent Conn receive Data from peer
Click to show internal directories.
Click to hide internal directories.