websocket

package
v0.0.0-...-2d343b4 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KindWebsocket transport.Kind = "websocket"
)

Variables

This section is empty.

Functions

func SetOperation

func SetOperation(ctx context.Context, op string)

SetOperation sets the transport operation.

Types

type Client

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

func NewClient

func NewClient(conn *ws.Conn, server *Server) *Client

func (*Client) Close

func (c *Client) Close()

func (*Client) Conn

func (c *Client) Conn() *ws.Conn

func (*Client) ConnectionID

func (c *Client) ConnectionID() string

func (*Client) Listen

func (c *Client) Listen()

func (*Client) SendMessage

func (c *Client) SendMessage(message *Message)

type ClientArray

type ClientArray []*Client

type ClientMap

type ClientMap map[string]*Client

type ConnectHandler

type ConnectHandler func(string, bool)

type EchoHandler

type EchoHandler func(string, *Message) (*Message, error)

type Handler

type Handler func(string, *Message) error

type Message

type Message struct {
	Body []byte
}

type Server

type Server struct {
	*http.Server
	// contains filtered or unexported fields
}

func NewServer

func NewServer(opts ...ServerOption) *Server

func (*Server) Broadcast

func (s *Server) Broadcast(message *Message)

func (*Server) ClientCount

func (s *Server) ClientCount() int

func (*Server) Endpoint

func (s *Server) Endpoint() (*url.URL, error)

func (*Server) Name

func (s *Server) Name() string

func (*Server) SendMessage

func (s *Server) SendMessage(connectionId string, message *Message)

func (*Server) Start

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

func (*Server) Stop

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

type ServerOption

type ServerOption func(o *Server)

func Address

func Address(addr string) ServerOption

func ConnectHandle

func ConnectHandle(h ConnectHandler) ServerOption

func EchoHandle

func EchoHandle(path string, h EchoHandler) ServerOption

func Listener

func Listener(lis net.Listener) ServerOption

func Logger

func Logger(logger log.Logger) ServerOption

func Network

func Network(network string) ServerOption

func ReadHandle

func ReadHandle(path string, h Handler) ServerOption

func TLSConfig

func TLSConfig(c *tls.Config) ServerOption

func Timeout

func Timeout(timeout time.Duration) ServerOption

type Transport

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

Transport is a websocket transport.

func (*Transport) Endpoint

func (tr *Transport) Endpoint() string

Endpoint returns the transport endpoint.

func (*Transport) Kind

func (tr *Transport) Kind() transport.Kind

Kind returns the transport kind.

func (*Transport) Operation

func (tr *Transport) Operation() string

Operation returns the transport operation.

func (*Transport) PathTemplate

func (tr *Transport) PathTemplate() string

PathTemplate returns the http path template.

func (*Transport) ReplyHeader

func (tr *Transport) ReplyHeader() transport.Header

ReplyHeader returns the reply header.

func (*Transport) Request

func (tr *Transport) Request() *http.Request

Request returns the HTTP request.

func (*Transport) RequestHeader

func (tr *Transport) RequestHeader() transport.Header

RequestHeader returns the request header.

type Transporter

type Transporter interface {
	transport.Transporter
	Request() *http.Request
	PathTemplate() string
}

Jump to

Keyboard shortcuts

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