controller

package
v0.0.0-...-6e05a96 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 22 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

View Source
const (
	// Time allowed to write a message to the peer.
	WriteWait = 10 * time.Second

	// Time allowed to read the next pong message from the peer.
	PongWait = 60 * time.Second

	// Send pings to peer with this period. Must be less than pongWait.
	PingPeriod = (PongWait * 9) / 10

	// Maximum message size allowed from peer.
	MaxMessageSize = 512
)

Variables

View Source
var InvalidRequestError = ErrorResponse{
	Error: "The request was invalid and not recognized",
}
View Source
var UnsupportedActionError = ErrorResponse{
	Error: "The requested action is not supported in this API",
}
View Source
var Upgrader = websocket.Upgrader{}

Functions

func ErrBadrequest

func ErrBadrequest(w http.ResponseWriter, r *http.Request, errorText string)

func ErrInternalServerError

func ErrInternalServerError(w http.ResponseWriter, r *http.Request, errorText string)

func ErrInvalidRequest

func ErrInvalidRequest(w http.ResponseWriter, r *http.Request)

func ErrUnsupportedAction

func ErrUnsupportedAction(w http.ResponseWriter, r *http.Request)

func WebsocketChl

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

Handles a ws connection request from user

Types

type Client

type Client struct {
	Hub *Hub

	// The websocket connection.
	Conn *websocket.Conn

	// Buffered channel of outbound messages.
	Send chan []byte

	// IP Address
	IPAddress string
	ID        uuid.UUID
	Accounts  []string // Subscribed accounts
	Currency  string
	// contains filtered or unexported fields
}

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

type ErrorResponse

type ErrorResponse struct {
	Error string `json:"error"`
}

type HttpController

type HttpController struct {
	RPCClient    *net.RPCClient
	BananoMode   bool
	FcmTokenRepo *repository.FcmTokenRepo
	FcmClient    *messaging.Client
}

func (*HttpController) HandleAction

func (hc *HttpController) HandleAction(w http.ResponseWriter, r *http.Request)

HandleHTTPRequest handles all requests to the http server It's generally designed to mimic the nano node's RPC API Though we do additional processing in the middle for some actions

func (*HttpController) HandleHTTPCallback

func (hc *HttpController) HandleHTTPCallback(w http.ResponseWriter, r *http.Request)

HTTP Callback is only for push notifications

type Hub

type Hub struct {
	// Registered clients.
	Clients map[*Client]bool

	// Outbound messages to the client
	Broadcast chan []byte

	// Register requests from the clients.
	Register chan *Client

	// Unregister requests from clients.
	Unregister chan *Client

	BananoMode  bool
	PricePrefix string

	RPCClient    *net.RPCClient
	FcmTokenRepo *repository.FcmTokenRepo
}

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

func NewHub

func NewHub(bananomode bool, rpcClient *net.RPCClient, fcmTokenRepo *repository.FcmTokenRepo) *Hub

func (*Hub) BroadcastToClient

func (h *Hub) BroadcastToClient(client *Client, message []byte)

func (*Hub) Run

func (h *Hub) Run()

Jump to

Keyboard shortcuts

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