api

package
v1.4.5 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2024 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(sockType types.SocketType, inst SocketInstance) (err error)

Types

type SockMessage added in v1.2.0

type SockMessage struct {
	Sock    Socket //socket handle
	Data    []byte //data received
	From    string //remote address for UDP
	MsgType int    //only for websocket
}

type Socket

type Socket interface {
	Listen() (err error)                                     // bind and listen on address and port
	Accept() Socket                                          // accept connection...
	Connect() (err error)                                    // for tcp/web socket
	Send(data []byte, to ...string) (n int, err error)       // send to...
	SendJson(v interface{}, to ...string) (n int, err error) // send json to...
	Recv(length int) (msg *SockMessage, err error)           // receive from... if length > 0, will receive the bytes specified.
	Close() (err error)                                      // close socket
	GetLocalAddr() string                                    // get socket local address
	GetRemoteAddr() string                                   // get socket remote address
	GetSocketType() types.SocketType                         // get socket type
}

func NewSocketInstance

func NewSocketInstance(sockType types.SocketType, ui *parser.UrlInfo, options ...SocketOption) (s Socket)

type SocketInstance

type SocketInstance func(ui *parser.UrlInfo, options ...SocketOption) Socket

type SocketOption added in v1.3.0

type SocketOption struct {
	CertFile string
	KeyFile  string
	Header   http.Header
	MsgType  int //websocket message type websocket.TextMessage/websocket.BinaryMessage
}

Jump to

Keyboard shortcuts

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