Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection interface {
Send(msg uint, data interface{}) error
SendAndReceive(msg uint, data interface{}, buf interface{}) error
SetHandler(msg uint, handler MessageHandler)
HandleMessage() error
Close() error
}
func Dial ¶
func Dial(network, address string) (Connection, error)
type ConnectionHandler ¶
type ConnectionHandler interface {
OnConnect(c Connection) error
OnClose(c Connection)
}
type MessageHandler ¶
type MessageHandler interface {
HandleMessage(c Connection, msg uint, data []byte) error
}
type Server ¶
type Server interface {
// Listen specified port to watch.
Listen(net, addr string) error
// SetHandler set handler for connection. The handler can add message
// handler for the connection, and clean-up resource on close.
SetHandler(handler ConnectionHandler)
// Loop handles connection requests. If it sees I/O errors, it
// automatically close port and return the error.
Loop() error
// Close the port, and it causes loop end.
Close() error
Addr() net.Addr
}
Click to show internal directories.
Click to hide internal directories.