com

package
v0.0.0-...-1a1e56d Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServerPort    = "8080"
	RootServerDir = "/chain/config"
)

Variables

This section is empty.

Functions

func NewServer

func NewServer(resources resources) *server

Types

type Client

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

This struct handles socket connection to the hub

func Connect

func Connect(host string) *Client

Connect to the hub

func (*Client) Close

func (client *Client) Close()

Close websocket

func (*Client) Receive

func (client *Client) Receive() map[string]interface{}

Get genesis

func (*Client) Send

func (client *Client) Send(message string)

Send infos

type CollectHandler

type CollectHandler func(message string) string

Collect member infos and return nil until the amount of members is reached

type CompleteHandler

type CompleteHandler func()

Complete the hub and end the listening

type GenerateHandler

type GenerateHandler func() map[string][]byte

Generate genesis if the amount of members is reached

type Hub

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

This struct handles multiple members socket to collect their infos and then send them back the output of the gathering (aka a genesis)

func NewHub

func NewHub(collect CollectHandler, generate GenerateHandler, complete CompleteHandler) *Hub

Create a hub

func (*Hub) HandleConnection

func (hub *Hub) HandleConnection(resp http.ResponseWriter, req *http.Request)

Handle a new member socket connection

func (*Hub) Listen

func (hub *Hub) Listen()

Listen to member actions

type Member

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

This struct handles socket connection in the Hub

type Message

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

type WebsocketHandler

type WebsocketHandler func(resp http.ResponseWriter, req *http.Request)

Jump to

Keyboard shortcuts

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