sockets

package
v0.0.0-...-c224b04 Latest Latest
Warning

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

Go to latest
Published: May 14, 2017 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// SocketChannel is the main channel where all chat messages are aggregated and passed to open web sockets
	SocketChannel = make(chan *SocketMessage, 10000)
)

Functions

func HandleWebSocketConnections

func HandleWebSocketConnections() echo.HandlerFunc

HandleWebSocketConnections sets up handling websocket connections for echo

func WriteToWebSocket

func WriteToWebSocket(ws *websocket.Conn, message []byte)

WriteToWebSocket is a quick helper function to write to an open web socket

Types

type Socket

type Socket struct {
	ID       string
	SendChan chan []byte
}

Socket holds information for a single socket

type SocketMessage

type SocketMessage struct {
	Message string `json:"message"`
	Source  string `json:"source"`
	User    string `json:"user"`
}

SocketMessage is used to submit a message entry back to websocket listeners. easyjson:json

func (SocketMessage) MarshalEasyJSON

func (v SocketMessage) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (SocketMessage) MarshalJSON

func (v SocketMessage) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*SocketMessage) UnmarshalEasyJSON

func (v *SocketMessage) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*SocketMessage) UnmarshalJSON

func (v *SocketMessage) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

Jump to

Keyboard shortcuts

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