messages

package
v0.0.0-...-a393644 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RemoveConnection

func RemoveConnection(ws *WebSocketContainer, g *Server)

func WriteJSON

func WriteJSON(ws *websocket.Conn, wsMutex *sync.Mutex, msg interface{}) error

Probably make this function part of the WebSocketContainer to ignore the first 2 params

func WriteMessage

func WriteMessage(ws *websocket.Conn, wsMutex *sync.Mutex, msg *string) error

Probably make this function part of the WebSocketContainer to ignore the first 2 params

Types

type BasicMessage

type BasicMessage struct {
	MsgType string `json:"msgtype"`
}

type Server

type Server struct {
	WalletIndex       map[string]string
	WsSockets         map[string]*WebSocketContainer
	Database          *data.Database
	LastBroadcastTime time.Time
	HandleMessage     func(g *Server, ws *WebSocketContainer, m BasicMessage, p []byte) error
	HandleDisconnect  func(ws *WebSocketContainer)
	// contains filtered or unexported fields
}

func NewServer

func NewServer(
	database *data.Database,
	handleMessage func(g *Server, ws *WebSocketContainer, m BasicMessage, p []byte) error,
	handleDisconnect func(ws *WebSocketContainer),
) *Server

func (*Server) WebSocketConnectionHandler

func (g *Server) WebSocketConnectionHandler(response http.ResponseWriter, request *http.Request)

func (*Server) WsHandler

func (g *Server) WsHandler(ws *WebSocketContainer)

type WebSocketContainer

type WebSocketContainer struct {
	Authenticated bool
	User          string
	WalletID      int
	WalletAddress string
	Conn          *websocket.Conn
	ConnMutex     *sync.Mutex
}

Jump to

Keyboard shortcuts

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