Documentation
¶
Index ¶
- func NewDialPlugin(rootPath string) drpc.Plugin
- func NewJSONServeHandler(endpoint drpc.Endpoint, handshake func(*websocket.Config, *http.Request) error) http.Handler
- func NewPbServeHandler(endpoint drpc.Endpoint, handshake func(*websocket.Config, *http.Request) error) http.Handler
- func NewServeHandler(endpoint drpc.Endpoint, handshake func(*websocket.Config, *http.Request) error, ...) http.Handler
- func NewWsProtoFunc(subProto ...proto.ProtoFunc) proto.ProtoFunc
- func QueryToken(tokenKey string, r *http.Request) (token string)
- type Acceptor
- type AfterWebsocketAcceptPlugin
- type BeforeWebsocketHandshakePlugin
- type Checker
- type Client
- type HandshakeAuthPlugin
- type Server
- func (that *Server) Close() error
- func (that *Server) Handle(rootPath string, handler http.Handler)
- func (that *Server) HandleFunc(rootPath string, handler func(http.ResponseWriter, *http.Request))
- func (that *Server) ListenAndServe(protoFunc ...proto.ProtoFunc) (err error)
- func (that *Server) ListenAndServeJSON() error
- func (that *Server) ListenAndServeProtobuf() error
- func (that *Server) SetHandshake(handshake func(*websocket.Config, *http.Request) error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewJSONServeHandler ¶
func NewJSONServeHandler(endpoint drpc.Endpoint, handshake func(*websocket.Config, *http.Request) error) http.Handler
NewJSONServeHandler 创建使用json格式编解码的处理器
func NewPbServeHandler ¶
func NewPbServeHandler(endpoint drpc.Endpoint, handshake func(*websocket.Config, *http.Request) error) http.Handler
NewPbServeHandler 创建使用protobuf协议编解码的处理器
func NewServeHandler ¶
func NewServeHandler(endpoint drpc.Endpoint, handshake func(*websocket.Config, *http.Request) error, protoFunc ...proto.ProtoFunc) http.Handler
NewServeHandler 创建处理器
func NewWsProtoFunc ¶
NewWsProtoFunc 创建websocket组件支持的编解码处理器 subProto: 真实的编解码协议,对endpoint来说,它打包和解包是使用了wsproto,实际wsproto是调用了子协议的打包和解包功能
Types ¶
type AfterWebsocketAcceptPlugin ¶
type AfterWebsocketAcceptPlugin interface { drpc.Plugin AfterAccept(sess drpc.Session, conn *websocket.Conn) *drpc.Status }
AfterWebsocketAcceptPlugin 在接收到websocket链接之后执行该插件
type BeforeWebsocketHandshakePlugin ¶
type BeforeWebsocketHandshakePlugin interface { drpc.Plugin BeforeHandshake(r *http.Request) *drpc.Status }
BeforeWebsocketHandshakePlugin 在websocket握手之前执行该插件
type Client ¶
Client websocket的rpc客户端
type HandshakeAuthPlugin ¶
HandshakeAuthPlugin 握手权限检查插件
func NewHandshakeAuthPlugin ¶
func NewHandshakeAuthPlugin(ckFn Checker, apFn Acceptor) *HandshakeAuthPlugin
NewHandshakeAuthPlugin 创建握手权限检查插件
func (*HandshakeAuthPlugin) AfterAccept ¶
AfterAccept 握手成功后,接受该链接后回调此方法
func (*HandshakeAuthPlugin) BeforeHandshake ¶
func (that *HandshakeAuthPlugin) BeforeHandshake(r *http.Request) *drpc.Status
BeforeHandshake 握手之前回调该方法,可以在此做权限认证的操作
func (*HandshakeAuthPlugin) Name ¶
func (that *HandshakeAuthPlugin) Name() string
type Server ¶
Server websocket 服务对象
func (*Server) HandleFunc ¶
HandleFunc 绑定路由到匿名方法
func (*Server) ListenAndServe ¶
ListenAndServe 监听地址端口并提供服务
func (*Server) ListenAndServeJSON ¶
ListenAndServeJSON 使用json协议传输数据
func (*Server) ListenAndServeProtobuf ¶
ListenAndServeProtobuf 使用protobuf协议传输数据
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package jsonSubProto 实现JSON套接字通信协议的。
|
Package jsonSubProto 实现JSON套接字通信协议的。 |
Package pbSubProto 实现PROTOBUF套接字通信协议的。
|
Package pbSubProto 实现PROTOBUF套接字通信协议的。 |
Click to show internal directories.
Click to hide internal directories.