websockets

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2018 License: GPL-3.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Chat client.

func NewClient

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

Create new chat client.

func (*Client) Conn

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

func (*Client) Done

func (c *Client) Done()

func (*Client) Listen

func (c *Client) Listen()

Listen Write and Read request via chanel

func (*Client) Write

func (c *Client) Write(msg *WebSocketPayload)

type Message

type Message struct {
	Id         string                 `json:"id"`
	Type       string                 `json:"type"`
	Attributes map[string]interface{} `json:"attributes"`
}

func (*Message) String

func (self *Message) String() string

type Server

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

Chat server.

func NewServer

func NewServer(pattern string, messageHandler WebSocketConnectionHandler) *Server

Create new chat server.

func (*Server) Add

func (s *Server) Add(c *Client)

func (*Server) Del

func (s *Server) Del(c *Client)

func (*Server) Done

func (s *Server) Done()

func (*Server) Err

func (s *Server) Err(err error)

func (*Server) Listen

func (s *Server) Listen(router *gin.Engine)

Listen and serve. It serves client connection and broadcast request.

type WebSocketConnectionHandler

type WebSocketConnectionHandler interface {
	MessageFromClient(message WebSocketPayload, request *http.Request)
}

type WebSocketPayload

type WebSocketPayload struct {
	Method  string  `json:"method"`
	Path    string  `json:"path"`
	Payload Message `json:"payload"`
}

Jump to

Keyboard shortcuts

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