websockets

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2017 License: GPL-3.0 Imports: 7 Imported by: 0

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