Documentation
¶
Index ¶
- type Client
- func (this *Client) Call(v []interface{}) []interface{}
- func (this *Client) Close(uint16)
- func (this *Client) Connect(fd uint16, s *network.Session)
- func (this *Client) Dial(addr string)
- func (this *Client) Heartbeat(fd uint16, sessionID uint16)
- func (this *Client) Message(fd uint16, sessionID uint16, body []byte)
- func (this *Client) Send(v []interface{})
- func (this *Client) SendCallBack(v []interface{}, callBack func(callRet interface{}))
- type Server
- func (this *Server) Close(fd uint16)
- func (this *Server) Connect(fd uint16, session *network.Session)
- func (this *Server) Heartbeat(fd uint16, sessionID uint16)
- func (this *Server) Message(fd uint16, sessionID uint16, body []byte)
- func (this *Server) Register(rcvr interface{})
- func (this *Server) RunFunc(m *methodType, args []reflect.Value) []interface{}
- func (this *Server) Start()
- type Service
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client 表示与远程服务进行通信的客户端
func (*Client) SendCallBack ¶ added in v0.0.6
func (this *Client) SendCallBack(v []interface{}, callBack func(callRet interface{}))
SendCallBack 发送数据到服务器,并在收到响应后执行回调函数
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server 表示RPC服务器,用于处理远程过程调用请求。 它维护了一个服务映射(serviceMap),包含了注册的RPC服务。 该服务器还包含一个TCP服务器(tcpServer),用于处理网络连接。 以及一个会话映射(sessions),用于跟踪和管理客户端会话。
func NewServer ¶
NewServer 创建一个新的RPC服务器实例。 参数 addr 是服务器监听的地址,通常是 IP 地址和端口号,例如 "localhost:8080"。 该函数会初始化一个服务映射(serviceMap),一个TCP服务器(tcpServer),以及一个会话映射(sessions)。 返回一个指向新服务器实例的指针。
func (*Server) Register ¶
func (this *Server) Register(rcvr interface{})
Register 注册一个RPC服务。 参数 rcvr 是一个接收器(receiver)对象,该对象包含了实现RPC方法的函数。 该方法会为接收器对象创建一个服务实例,并将服务名称、方法信息等注册到服务器。
Click to show internal directories.
Click to hide internal directories.