p2p

package
v0.0.0-...-eac8cab Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GameState

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

func NewGameState

func NewGameState() *GameState

type GameStatus

type GameStatus uint32
const (
	GameStatusWaiting GameStatus = iota
	GameStatusDealing
	GameStatusPreFlop
	GameStatusFlop
	GameStatusTurn
	GameStatusRiver
)

func (GameStatus) String

func (gs GameStatus) String() string

type GameVariant

type GameVariant uint8
const (
	TexasHoldem GameVariant = iota
	Other
)

func (GameVariant) String

func (gv GameVariant) String() string

type Handshake

type Handshake struct {
	Version     string
	GameVariant GameVariant
	GameStatus  GameStatus
}

type Message

type Message struct {
	Payload io.Reader
	From    net.Addr
}

type Peer

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

func (*Peer) ReadLoop

func (p *Peer) ReadLoop(msgCh chan *Message)

func (*Peer) Send

func (p *Peer) Send(data []byte) error

type Server

type Server struct {
	ServerConfig
	// contains filtered or unexported fields
}

func NewServer

func NewServer(cfg ServerConfig) *Server

func (*Server) Connect

func (s *Server) Connect(addr string) error

TODO: redundant code in Connect and acceptLoop

func (*Server) HandleMessage

func (s *Server) HandleMessage(msg *Message) error

func (*Server) SendHandshake

func (s *Server) SendHandshake(p *Peer) error

func (*Server) Start

func (s *Server) Start()

type ServerConfig

type ServerConfig struct {
	ListenAddr  string
	Version     string
	GameVariant GameVariant
}

type TCPTransport

type TCPTransport struct {
	AddPeer chan *Peer
	DelPeer chan *Peer
	// contains filtered or unexported fields
}

func NewTCPTransport

func NewTCPTransport(listenAddr string) *TCPTransport

func (*TCPTransport) ListenAndAccept

func (t *TCPTransport) ListenAndAccept() error

Jump to

Keyboard shortcuts

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