net

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KILL = "kill"
)

Variables

This section is empty.

Functions

func NetConn

func NetConn(ctx *context.Context, event signals.Signal[[]byte], outEvent *signals.Signal[[]byte], terminateSignal *signals.Signal[string], c ClientHandler) net.Conn

func ReceiveUDP

func ReceiveUDP(conn net.Conn) ([]byte, error)

func SendUDP

func SendUDP(conn net.Conn, message []byte) error

Types

type BinaryEvent

type BinaryEvent struct {
	Data []byte
}

type ClientHandler

type ClientHandler interface {
	Close() error
	Write(p []byte) error
}

type ClientWSWrapper

type ClientWSWrapper struct {
	Conn    *websocket.Conn
	Context context.Context
	// contains filtered or unexported fields
}

func (ClientWSWrapper) Close

func (c ClientWSWrapper) Close() error

func (ClientWSWrapper) Write

func (c ClientWSWrapper) Write(p []byte) error

type ConnectionOptions

type ConnectionOptions struct {
	UseCompression bool
	UseSSL         bool
	Proxy          func(*http.Request) (*url.URL, error)
	Subprotocols   []string
}

type Empty

type Empty struct {
}

type ISocket

type ISocket interface {
	SocketHandler() *SocketHandler
	Connect()
	Close()
	SendBinary(data []byte)
	IsConnected() bool
	ClientHandler() ClientHandler
}

func NewKCPSocket

func NewKCPSocket(address string, key string) ISocket

func NewWebSocket

func NewWebSocket(url string) ISocket

type KCPSocket

type KCPSocket struct {
	Address string

	Timeout time.Duration
	// contains filtered or unexported fields
}

func (*KCPSocket) ClientHandler

func (socket *KCPSocket) ClientHandler() ClientHandler

func (*KCPSocket) Close

func (socket *KCPSocket) Close()

func (*KCPSocket) Connect

func (socket *KCPSocket) Connect()

func (*KCPSocket) IsConnected

func (socket *KCPSocket) IsConnected() bool

func (*KCPSocket) SendBinary

func (socket *KCPSocket) SendBinary(data []byte)

func (*KCPSocket) SocketHandler

func (socket *KCPSocket) SocketHandler() *SocketHandler

type KCPSocketHandler

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

func (KCPSocketHandler) Close

func (c KCPSocketHandler) Close() error

func (KCPSocketHandler) Write

func (c KCPSocketHandler) Write(p []byte) error

type MessageEvent

type MessageEvent struct {
	Message interface{}
}

type PingEvent

type PingEvent struct{}

type ReconnectionOptions

type ReconnectionOptions struct {
}

todo Yet to be done

type Socket

type Socket struct {
	WebSocketConn     *websocket.Conn
	Context           context.Context
	Url               string
	ConnectionOptions ConnectionOptions
	RequestHeader     http.Header

	Timeout time.Duration
	// contains filtered or unexported fields
}

func (Socket) ClientHandler

func (socket Socket) ClientHandler() ClientHandler

func (Socket) Close

func (socket Socket) Close()

func (Socket) Connect

func (socket Socket) Connect()

func (Socket) EnableLogging

func (socket Socket) EnableLogging()

func (Socket) IsConnected

func (socket Socket) IsConnected() bool

func (Socket) SendBinary

func (socket Socket) SendBinary(data []byte)

func (Socket) SocketHandler

func (socket Socket) SocketHandler() *SocketHandler

type SocketHandler

type SocketHandler struct {
	OnConnected     func(socket interface{})
	OnTextMessage   func(message string, socket interface{})
	OnBinaryMessage func(data []byte, socket interface{})
	OnConnectError  func(err error, socket interface{})
	OnDisconnected  func(err error, socket interface{})
	OnPingReceived  func(data string, socket interface{})
	OnPongReceived  func(data string, socket interface{})
}

Jump to

Keyboard shortcuts

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