Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
// DefaultAddr defines the default Websocket server address.
DefaultAddr = "127.0.0.1:8080"
)
Functions ¶
This section is empty.
Types ¶
type Connections ¶
type Connections struct {
// contains filtered or unexported fields
}
Connections keeps track of active Websocket connections.
func NewConnections ¶
func NewConnections() *Connections
NewConnections create a new Websocket connections registry.
func (*Connections) Add ¶
func (c *Connections) Add(ws *websocket.Conn)
Add adds a new Websocket connection to the registry.
func (*Connections) Delete ¶
func (c *Connections) Delete(ws *websocket.Conn) error
Delete removes a Websocket connection from the registry. Connections are closed after being removed.
func (*Connections) IsEmpty ¶
func (c *Connections) IsEmpty() bool
IsEmpty checks if there are registered connections.
type Option ¶
type Option func(*Server)
Option configures transaction broadcast servers.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server handles Websocket connections and broadcasts new transactions. It watches the transactions head file and when new transactions are indexed it pushes the new entries to the connected clients.
func (*Server) HandleWS ¶
func (s *Server) HandleWS(w http.ResponseWriter, r *http.Request)
HandleWS is an HTTP handler that upgrades incoming connections to WS or WSS.
Click to show internal directories.
Click to hide internal directories.