gather

package
v0.0.0-...-ce9d6f3 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2021 License: BSD-3-Clause Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConnectionRequest = iota + 1
	Connected
	Disconnected
	GatheringFinished
)
View Source
const ID = "/snake/gather/0.1.0"

Variables

This section is empty.

Functions

func HostAddrInfo

func HostAddrInfo(h host.Host) *peer.AddrInfo

Types

type GatherMessage

type GatherMessage struct {
	Type  GatherMessageType
	Addrs []peer.AddrInfo
}

GatherMessage represents a set of all different messages possible to be sent in the gather protocol. This kind of all-in-one message is only possible because of the simplicity of the protocol bus is potentially inefficient. If any of the message types were to have additional fields, the messages of all other types would have to have these additional fields, even though they don't need them. (TODO: consider protobuf).

type GatherMessageType

type GatherMessageType int

type GatherPointBeacon

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

func NewGatherPointBeacon

func NewGatherPointBeacon(topic *pubsub.Topic, self peer.AddrInfo, n int, TTL time.Duration) *GatherPointBeacon

func (*GatherPointBeacon) Close

func (b *GatherPointBeacon) Close()

type GatherPointMessage

type GatherPointMessage struct {
	ConnectTo          peer.AddrInfo
	TTL                time.Duration
	DesiredPlayerCount uint
	CurrentPlayerCount uint
}

type GatherService

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

func NewGatherService

func NewGatherService(h host.Host, topic *pubsub.Topic, game *game.GameService, ping *ping.PingService, n int, TTL time.Duration, gameCh chan<- game.GameEstablished) (*GatherService, error)

func (*GatherService) Close

func (gs *GatherService) Close()

func (*GatherService) GatherHandler

func (gs *GatherService) GatherHandler(stream network.Stream)

type JoinService

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

func NewJoinService

func NewJoinService(ctx context.Context, h host.Host, game *game.GameService, ping *ping.PingService, pID peer.ID, gameCh chan<- game.GameEstablished) (*JoinService, error)

func (*JoinService) Close

func (js *JoinService) Close()

Jump to

Keyboard shortcuts

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