bus

package
v0.0.0-...-e6555c8 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2022 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const EventTypeAttackFinished = "attack_finished"
View Source
const EventTypeAttackInitiated = "attack_initiated"
View Source
const EventTypeDefenseFailed = "defense_failed"
View Source
const EventTypeDefenseModuleInstalled = "defense_module_installed"
View Source
const EventTypePanic = "panic"
View Source
const EventTypePlayerJoined = "player_joined"
View Source
const EventTypeRegistration = "registration"

Enums

Variables

This section is empty.

Functions

This section is empty.

Types

type AttackFinishedEvent

type AttackFinishedEvent struct {
	AttackerName  string
	ChallengeName string
	Success       bool
}

Describes a success or a fail for an attack

type AttackInitiatedEvent

type AttackInitiatedEvent struct {
	AttackerName  string
	ChallengeName string
}

Happens when a new attack is started

type Bus

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

Event bus implementation

func (Bus) Listen

func (b Bus) Listen(topic string) <-chan *BusEvent

func (Bus) Send

func (b Bus) Send(event *BusEvent)

func (Bus) Stop

func (b Bus) Stop()

type BusEvent

type BusEvent struct {
	Type        string
	Information interface{}
}

Describes a message sent to the bus

func (BusEvent) DecodeAttackFinishedEvent

func (be BusEvent) DecodeAttackFinishedEvent() (*AttackFinishedEvent, error)

Decodes an attack finished event

func (BusEvent) DecodeAttackInitiatedEvent

func (be BusEvent) DecodeAttackInitiatedEvent() (*AttackInitiatedEvent, error)

Decodes an attack initiated event

func (BusEvent) DecodeDefenseFailedEvent

func (be BusEvent) DecodeDefenseFailedEvent() (*DefenseFailedEvent, error)

Decodes a defense failed event

func (BusEvent) DecodeDefenseModuleInstalledEvent

func (be BusEvent) DecodeDefenseModuleInstalledEvent() (*DefenseModuleInstalledEvent, error)

Decodes a defense module installed event

func (BusEvent) DecodePlayerJoinedEvent

func (be BusEvent) DecodePlayerJoinedEvent() (*PlayerJoinedEvent, error)

Decodes a player joined event

func (BusEvent) DecodeRegistrationEvent

func (be BusEvent) DecodeRegistrationEvent() (*RegistrationEvent, error)

Decodes a registration event

type DefenseFailedEvent

type DefenseFailedEvent struct {
	DefenderName string
	AttackerName string
}

Happens when a defender fails to defend their module

type DefenseModuleInstalledEvent

type DefenseModuleInstalledEvent struct {
	Name        string
	CreatorName string
}

Happens when a new defense module is added to the system

type IBus

type IBus interface {
	// Provides a channel that can be listened for a given topic
	Listen(topic string) <-chan *BusEvent
	// Send a new event to the event bus
	Send(event *BusEvent)
	// Graceful shutdown
	Stop()
}

Describes the interface of the common event bus

func NewBus

func NewBus() IBus

Constructor for event bus

type PlayerJoinedEvent

type PlayerJoinedEvent struct {
	Name string
	Team string
}

Player joined the live game event

type RegistrationEvent

type RegistrationEvent struct {
	Name string
	Team string
	ID   string
}

Describes a registration event

Jump to

Keyboard shortcuts

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