watched

package module
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2024 License: AGPL-3.0 Imports: 15 Imported by: 4

README

Watch Elite: Dangerous Journal Files

This is a Go library to watch Journal files of Elite: Dangerous. The commander's Journal is official way to hook player tools into E:D.

This root package only defines some abstractions for event processing. This gives developers the opportunity to build different processing strategies for the events coming from ED.

Building

Using watched as a library does not need anything special. Just

import "github.com/CmdrVasquess/watched"

in your application.

If you want to build edeh and use it right in place, you have to build the project. Want to get platform independent, instead of make try to use

$ go run mk/mk.go

Documentation

Index

Constants

View Source
const (
	StatBackpackName = "Backpack"
	StatCargoName    = "Cargo"
	StatFCMatsName   = "FCMaterials"
	StatMarketName   = "Market"
	StatModulesName  = "Modules"
	StatNavRouteName = "NavRoute"
	StatOutfitName   = "Outfitting"
	StatLockerName   = "ShipLocker"
	StatShipyardName = "Shipyard"
	StatStatusName   = "Status"
)

Variables

This section is empty.

Functions

func FindJournalDir added in v0.8.0

func FindJournalDir() (dir string, err error)

func IsJournalFile

func IsJournalFile(name string) (format int)

Format 1: Journal.201206082715.01.log Format 2: Journal.2023-12-27T134309.01.log

func JournalFileCmpr added in v0.8.0

func JournalFileCmpr(f, g string) int

func NewestJournal

func NewestJournal(inDir string) (res string, err error)

TODO Use [JouralFileCmpr]

func Peek added in v0.6.0

func Peek(str []byte) (t time.Time, event string, err error)

func PeekEvent added in v0.6.0

func PeekEvent(str []byte) (event string, err error)

func PeekTime added in v0.6.0

func PeekTime(str []byte) (t time.Time, err error)

func SetLog added in v0.8.0

func SetLog(l *slog.Logger)

Types

type BranchConfig added in v0.6.0

type BranchConfig struct {
	JournalQLen int
	StatusQLen  int
}

type EventRecv added in v0.6.0

type EventRecv interface {
	OnJournalEvent(e JounalEvent) error
	OnStatusEvent(e StatusEvent) error
	Close() error
}

type EventSrc added in v0.6.0

type EventSrc struct {
	Journal <-chan JounalEvent
	Status  <-chan StatusEvent
}

type JounalEvent added in v0.6.0

type JounalEvent struct {
	File    string
	EventNo int
	Event   RawEvent
}

func (*JounalEvent) Clone added in v0.8.0

func (e *JounalEvent) Clone() JounalEvent

type Journal added in v0.8.0

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

func NewJournal added in v0.8.0

func NewJournal(dir string, r EventRecv, opt *JournalOptions) *Journal

func (*Journal) Start added in v0.8.0

func (ede *Journal) Start() (err error)

func (*Journal) Stop added in v0.8.0

func (ede *Journal) Stop()

type JournalOptions added in v0.8.0

type JournalOptions struct {
	SerialIndependent []string
}

type JournalProgress added in v0.8.0

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

func (*JournalProgress) EventNo added in v0.8.0

func (jp *JournalProgress) EventNo() int

func (*JournalProgress) File added in v0.8.0

func (jp *JournalProgress) File() string

func (*JournalProgress) IsNew added in v0.8.0

func (jp *JournalProgress) IsNew(file string, n int) bool

func (*JournalProgress) Reset added in v0.8.0

func (jp *JournalProgress) Reset()

func (*JournalProgress) Set added in v0.8.0

func (jp *JournalProgress) Set(file string, n int) error

type RawEvent added in v0.6.0

type RawEvent []byte

func (RawEvent) Peek added in v0.6.0

func (re RawEvent) Peek() (time.Time, string, error)

func (RawEvent) PeekEvent added in v0.6.0

func (re RawEvent) PeekEvent() (string, error)

func (RawEvent) PeekTime added in v0.6.0

func (re RawEvent) PeekTime() (time.Time, error)

type RecvToSrc added in v0.6.0

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

func (*RecvToSrc) Branch added in v0.6.0

func (rs *RecvToSrc) Branch(cfg BranchConfig) EventSrc

func (*RecvToSrc) Close added in v0.6.0

func (rs *RecvToSrc) Close() error

func (*RecvToSrc) OnJournalEvent added in v0.6.4

func (rs *RecvToSrc) OnJournalEvent(e JounalEvent) error

func (*RecvToSrc) OnStatusEvent added in v0.6.4

func (rs *RecvToSrc) OnStatusEvent(e StatusEvent) error

type StatusEvent added in v0.6.0

type StatusEvent struct {
	Type  StatusType
	Event RawEvent
}

func (*StatusEvent) Clone added in v0.8.0

func (e *StatusEvent) Clone() StatusEvent

type StatusType added in v0.6.0

type StatusType int
const (
	StatBackpack StatusType = iota + 1
	StatCargo
	StatFCMats
	StatMarket
	StatModules
	StatNavRoute
	StatOutfit
	StatLocker
	StatShipyard
	StatStatus

	EndStatusType
)

func IsStatusFile added in v0.8.0

func IsStatusFile(name string) StatusType

func ParseStatusType added in v0.6.0

func ParseStatusType(s string) StatusType

func (StatusType) String added in v0.6.0

func (st StatusType) String() string

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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