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: ? 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

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