pigeon

package
Version: v0.0.0-...-fce0f90 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2020 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	ID          string    `json:"id"`
	Username    string    `json:"username"`
	ConnectedAt time.Time `json:"connected_at"`
}

Client contains all fields required for pigeon.

type Message

type Message struct {
	ID        string    `json:"id"`
	Client    Client    `json:"client"`
	Message   string    `json:"message"`
	Connected bool      `json:"connected"`
	Timestamp time.Time `json:"timestamp"`
}

Message contains all fields required to send a message with pigeon.

type Pigeon

type Pigeon struct {
	Clients          map[*websocket.Conn]Client
	Broadcast        chan Message
	BroadcastHistory []Message
	Register         chan *websocket.Conn
	Unregister       chan *websocket.Conn
	Server           *http.Server
	Upgrader         *websocket.Upgrader
	OnionURL         string
	RemotePort       int
	TorVersion3      bool
	Logger           *log.Logger
	Debug            bool
}

Pigeon is the object that stores all clients, messages, and configuration options.

func (*Pigeon) BroadcastMessages

func (p *Pigeon) BroadcastMessages()

BroadcastMessages continuously loops and checks if it needs to add a new client, remove a current client, or broadcast any message received from a client to all other clients.

func (*Pigeon) Init

func (p *Pigeon) Init(ctx context.Context) (*tor.Tor, *tor.OnionService, error)

Init initializes the pigeon object and all of its options and dependencies.

func (*Pigeon) Log

func (p *Pigeon) Log(str string, args ...interface{})

Log is a helper function to only log if debug is enabled.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL