Documentation ¶
Index ¶
Constants ¶
View Source
const ( CallTypeNone = 0 CallTypeLoop = 1 CallTypeOnce = 2 CallTypeCancel = 3 )
Variables ¶
View Source
var ErrNotSuportType = errors.New("type is not suported")
View Source
var ErrPendingTooLong = errors.New("call is pending too long")
View Source
var ErrSendError = errors.New("got error when send to network")
View Source
var ErrShutdown = errors.New("connection is shut down")
Functions ¶
Types ¶
type Call ¶
type Call struct { Args interface{} // Args作为请求的body ReplyType reflect.Type // 需要的返回值类型 (*struct) MethodNO uint32 //请求类型 Done func(reply interface{}, err error) //在收到返回值或未能正确调用的时候调用 Type uint32 //调用类型,只发不等待请求数据,none:0;一次请求循环多次接收,loop:1; 一次请求一次接收,once:2;取消调用:cancel:3 TimeOut int64 //超时时间,超市部分赶回,则代表调用失败 }
type Client ¶
func NewClient ¶
func NewClient(conn io.ReadWriteCloser) *Client
type ClientCodec ¶
type IMsg ¶
type IMsg interface { RecvMsg(logT *log.TraceInfoST) (msgs PkgRtn, err error) //MsgNO() uint16 //返回对应的消息编号,每种消息一个编号,保证唯一性 IMsgRtn }
IMsg 是路由层(消息分发层)和逻辑层(消息处理层)之间传递的数据结构,Msg:message的缩写
type IMsgRtn ¶
type IMsgRtn interface {
MsgNO() uint16 //消息编号
}
IMsgRtn 是路由层(消息分发层)和逻辑层(消息处理层)之间传递的数据结构,Msg:message的缩写
type Pkg ¶
type Pkg struct { Msg IMsg //gob的每个请求都有一个自动增加的针对连接唯一的编号,相当于是一个session, //当client收到数据时,client会根据编号调用回调函数, //所以,server端收到消息后,必须保存消息的编号,以便在回复消息的时候有目的地! Seq uint64 }
Pkg 每次收到消息,通过这个结构包装后写到channel中
type PkgRtn ¶
type PkgRtn struct { Msg IMsgRtn Seq uint64 //gob的每个请求都有一个自动增加的针对连接唯一的编号,相当于是一个session LogT *log.TraceInfoST }
MsgRtn 是RecvMsg()方法的返回值,Msg:message的缩写,Rtn:return的缩写
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server 一条连接一个Server,连接的相关的信息可以存这里
type ServerCodec ¶
type ServerError ¶
type ServerError string
func (ServerError) Error ¶
func (e ServerError) Error() string
Click to show internal directories.
Click to hide internal directories.