网络开发整体框架
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
746 B

package hpds_net_framework
import (
"net"
)
// Server interface
type Server interface {
Run() error
Handle(conn net.Conn)
}
// INode 网络同步节点,如消息节点,聊天室节点
type INode interface {
AddConn(IConnection) error
DelConn(string) error
Serve()
OnRawMessage([]byte) error
OnProtocolMessage(interface{}) error
GetAllMessage() chan []interface{}
Destroy() error
Complete() error
}
// IConnection 网络连接
type IConnection interface {
GetUuid() string
ReadMsg()
WriteMsg(message interface{})
Close() error
AfterClose(func())
//SetData 设置自定义数据
SetData(interface{})
GetData() interface{}
//SetNode 设置节点
SetNode(INode)
GetNode() INode
//IsClosed 是否关闭
IsClosed() bool
}