websocket

package
v0.0.0-...-a86c0c9 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(id, name string, options *ClientOptions) dal.Client

func NewServer

func NewServer(listen string, service nameing.ServerRegistration) dal.Server

Types

type Client

type Client struct {
	sync.Mutex
	dal.Dialer
	// contains filtered or unexported fields
}

func (*Client) Close

func (c *Client) Close()

func (*Client) Connect

func (c *Client) Connect(addr string) error

func (*Client) ID

func (c *Client) ID() string

func (*Client) Name

func (c *Client) Name() string

func (*Client) Read

func (c *Client) Read() (dal.Frame, error)

func (*Client) Send

func (c *Client) Send(payload []byte) error

func (*Client) SetDialer

func (c *Client) SetDialer(dialer dal.Dialer)

type ClientOptions

type ClientOptions struct {
	Heartbeat time.Duration //登录超时
	ReadWait  time.Duration //读超时
	WriteWait time.Duration //写超时
}

type Frame

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

func (*Frame) GetOpCode

func (f *Frame) GetOpCode() constants.OpCode

func (*Frame) GetPayload

func (f *Frame) GetPayload() []byte

func (*Frame) SetOpCode

func (f *Frame) SetOpCode(opCode constants.OpCode)

func (*Frame) SetPayload

func (f *Frame) SetPayload(raw []byte)

type Server

type Server struct {
	nameing.ServerRegistration
	dal.ChannelMap
	dal.Acceptor
	dal.MessageListener
	dal.StateListener
	// contains filtered or unexported fields
}

func (*Server) Push

func (s *Server) Push(s2 string, bytes []byte) error

func (*Server) SetAcceptor

func (s *Server) SetAcceptor(acceptor dal.Acceptor)

func (*Server) SetChannelMap

func (s *Server) SetChannelMap(channelMap dal.ChannelMap)

func (*Server) SetMessageListener

func (s *Server) SetMessageListener(listener dal.MessageListener)

func (*Server) SetReadWait

func (s *Server) SetReadWait(duration time.Duration)

func (*Server) SetStateListener

func (s *Server) SetStateListener(listener dal.StateListener)

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

func (*Server) Start

func (s *Server) Start() error

type ServerOptions

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

type WsConn

type WsConn struct {
	net.Conn
}

func NewWsConn

func NewWsConn(conn net.Conn) *WsConn

func (*WsConn) Flush

func (c *WsConn) Flush() error

func (*WsConn) ReadFrame

func (c *WsConn) ReadFrame() (dal.Frame, error)

func (*WsConn) WriteFrame

func (c *WsConn) WriteFrame(opCode constants.OpCode, payload []byte) error

Jump to

Keyboard shortcuts

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