websocket

package
v0.0.0-...-c0a7596 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2022 License: MIT 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, opts ClientOptions) goim.Client

NewClient NewClient

func NewServer

func NewServer(listen string, service naming.ServiceRegistration) goim.Server

NewServer NewServer

Types

type Client

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

Client is a websocket implement of the terminal

func (*Client) Close

func (c *Client) Close()

func (*Client) Connect

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

Connect to server

func (*Client) ID

func (c *Client) ID() string

func (*Client) Name

func (c *Client) Name() string

func (*Client) Read

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

Read client

func (*Client) Send

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

func (*Client) SetDialer

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

type ClientOptions

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

ClientOptions ClientOptions

type Frame

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

Frame 帧协议

func NewFrame

func NewFrame(raw ws.Frame) *Frame

NewFrame 创建帧

func (*Frame) GetOpCode

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

GetOpCode 获取帧类型

func (*Frame) GetPayload

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

GetPayload 获取帧数据

func (*Frame) SetOpCode

func (f *Frame) SetOpCode(op goim.OpCode)

SetOpCode 设置帧类型

func (*Frame) SetPayload

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

SetPayload 设置帧数据

type Server

type Server struct {
	naming.ServiceRegistration
	goim.ChannelMap
	goim.Acceptor
	goim.MessageListener
	goim.StateListener
	// contains filtered or unexported fields
}

Server is a websocket implement of the Server

func (*Server) Push

func (s *Server) Push(id string, data []byte) error

string channelID []byte data

func (*Server) SetAcceptor

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

SetAcceptor SetAcceptor

func (*Server) SetChannelMap

func (s *Server) SetChannelMap(channels goim.ChannelMap)

SetChannels SetChannels

func (*Server) SetMessageListener

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

SetMessageListener SetMessageListener

func (*Server) SetReadWait

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

SetReadWait set read wait duration

func (*Server) SetStateListener

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

SetStateListener SetStateListener

func (*Server) Shutdown

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

Shutdown Shutdown

func (*Server) Start

func (s *Server) Start() error

Start server

type ServerOptions

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

ServerOptions ServerOptions

type WsConn

type WsConn struct {
	net.Conn
}

WsConn WebSocket连接

func NewConn

func NewConn(conn net.Conn) *WsConn

NewConn 创建连接

func (*WsConn) Flush

func (c *WsConn) Flush() error

func (*WsConn) ReadFrame

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

ReadFrame 读取帧

func (*WsConn) WriteFrame

func (c *WsConn) WriteFrame(code goim.OpCode, payload []byte) error

WriteFrame 写入帧

Jump to

Keyboard shortcuts

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