Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChanListener ¶
type ChanListener struct {
// contains filtered or unexported fields
}
ChanListener .
func (*ChanListener) Accept ¶
func (l *ChanListener) Accept() (net.Conn, error)
Accept accepts a connection.
func (*ChanListener) Addr ¶
func (l *ChanListener) Addr() net.Addr
Addr returns the listener's network address.
func (*ChanListener) Close ¶
func (l *ChanListener) Close() error
Close does nothing but implementing net.Conn.Close. User should call ListenerMux.Close to close it automatically.
func (*ChanListener) Decrease ¶
func (l *ChanListener) Decrease()
Decrease decreases the online num if it's A.
type ListenerMux ¶
type ListenerMux struct {
// contains filtered or unexported fields
}
ListenerMux manages listeners and handle the connection dispatching logic.
func (*ListenerMux) DecreaseOnlineA ¶
func (lm *ListenerMux) DecreaseOnlineA()
DecreaseOnlineA decreases the online num of ChanListener A.
func (*ListenerMux) Mux ¶
func (lm *ListenerMux) Mux(l net.Listener) (*ChanListener, *ChanListener)
Mux creates and returns ChanListener A and B: If the online num of A is less than ListenerMux. maxOnlineA, the new connection will be dispatched to A; Else the new connection will be dispatched to B.
func (*ListenerMux) Start ¶
func (lm *ListenerMux) Start()
Start starts to accept and dispatch the connections to ChanListener A or B.