ws

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Middleware

func Middleware(h http.Handler, middleware ...func(http.Handler) http.Handler) http.Handler

Types

type AuthApiKeyValidateFunc

type AuthApiKeyValidateFunc func(apiKey string) bool

ws header auth: by api-key

type Message

type Message struct {
	// contains filtered or unexported fields
}

ws message format:

func (*Message) FromJson

func (m *Message) FromJson(from string) (err error)

func (*Message) FromProtoBuf

func (m *Message) FromProtoBuf(from string) (err error)

protobuf:

func (*Message) ToJson

func (m *Message) ToJson() (to map[string]interface{}, err error)

func (*Message) ToProtoBuf

func (m *Message) ToProtoBuf() (to map[string]interface{}, err error)

type MessageHandlerFunc

type MessageHandlerFunc func(receivedMessage []byte) (responseMessage []byte, err error)

接收消息+处理+生成待发送消息:

type SocketIOEndpoint

type SocketIOEndpoint struct {
	Endpoint string
	Handler  SocketIOMessageHandlerFunc
}

type SocketIOMessageHandlerFunc

type SocketIOMessageHandlerFunc func(client *v2.Client, request *v2.Request) *v2.Message

type SocketIOOption

type SocketIOOption struct {
	Addr string

	Endpoints []SocketIOEndpoint
}

type SocketIOServer

type SocketIOServer struct {
	// contains filtered or unexported fields
}

server side:

func NewSocketIOServer

func NewSocketIOServer(opt *SocketIOOption) *SocketIOServer

func (*SocketIOServer) RunV2

func (m *SocketIOServer) RunV2(port int)

type WebSocketClient

type WebSocketClient struct {
	// contains filtered or unexported fields
}

client side:

func NewWebSocketClient

func NewWebSocketClient() *WebSocketClient

type WebSocketOption

type WebSocketOption struct {
	Addr string
	Host string
	Port int
	// contains filtered or unexported fields
}

func (*WebSocketOption) Uri

func (m *WebSocketOption) Uri() string

type WebSocketServer

type WebSocketServer struct {
	// contains filtered or unexported fields
}

server side:

func NewWebSocketServer

func NewWebSocketServer(msgHandler MessageHandlerFunc, authValidator AuthApiKeyValidateFunc) *WebSocketServer

func (*WebSocketServer) Dispatch

func (m *WebSocketServer) Dispatch(w http.ResponseWriter, r *http.Request)

处理消息:

func (*WebSocketServer) DispatchWithAuth

func (m *WebSocketServer) DispatchWithAuth(middleware ...func(http.Handler) http.Handler) (h http.Handler)

鉴权: http header key

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL