socket

package
v0.0.0-...-b3031ee Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2021 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ServeWs

func ServeWs(hub *Hub, w http.ResponseWriter, r *http.Request)

ServeWs handles websocket requests from the peer.

Types

type Client

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

Client is a middleman between the websocket connection and the hub.

func NewClient

func NewClient(hub *Hub, conn *websocket.Conn) *Client

type ErrorCode

type ErrorCode int
const (
	BadLogin ErrorCode = iota + 1
	HighSchoolNightClub
	MissingProjectForm
	HighSchoolSponsorQueue
	MissingSurveyResponse
	NonMitMisti
)

type Hub

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

Hub maintains the set of active clients and broadcasts messages to the clients

func (*Hub) Init

func (h *Hub) Init() *Hub

func (*Hub) ProcessRedisMessage

func (h *Hub) ProcessRedisMessage(msg []byte)

Processes an incoming message from Redis

func (*Hub) Run

func (h *Hub) Run()

Listens for messages from websocket clients

func (*Hub) Send

func (h *Hub) Send(msg encoding.BinaryMarshaler)

Sends a message to all of our clients

func (*Hub) SendBytes

func (h *Hub) SendBytes(room string, msg []byte)

type SocketMessage

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

SocketMessage stores messages sent over WS with the client who sent it

func (SocketMessage) MarshalBinary

func (m SocketMessage) MarshalBinary() ([]byte, error)

func (SocketMessage) UnmarshalBinary

func (m SocketMessage) UnmarshalBinary(data []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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