wsconn

package
Version: v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Payload

type Payload struct {
	Success   bool   `json:"success"`
	Type      string `json:"type,omitempty"`
	Message   string `json:"message,omitempty"`
	IPAddress string `json:"ip,omitempty"`
	Key       string `json:"key,omitempty"`
}

Payload lists the data exchanged

func (Payload) String

func (p Payload) String() string

type WebsocketConn

type WebsocketConn struct {
	sync.Mutex
	// contains filtered or unexported fields
}

WebsocketConn provides convenience functions for sending and receiving data with websockets, using mutex to make sure only one writer/reader

func New

func New(ws *websocket.Conn) *WebsocketConn

NewWebsocket returns a new websocket

func (*WebsocketConn) Close

func (ws *WebsocketConn) Close() (err error)

func (*WebsocketConn) Receive

func (ws *WebsocketConn) Receive() (p Payload, err error)

func (*WebsocketConn) Send

func (ws *WebsocketConn) Send(p Payload) (err error)

Source Files

Jump to

Keyboard shortcuts

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