frontend

package
v0.0.0-...-3e265c8 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AprilshMsgOpen     = "open aprilsh:"
	AprishMsgClose     = "close aprilsh:"
	AprilshPackageName = "aprilsh"
	CommandServerName  = "apshd"
	CommandClientName  = "apsh"
	TimeoutIfNoResp    = 60000
	TimeoutIfNoConnect = 15000

	VersionInfo = `` /* 283-byte string literal not displayed */

)
View Source
const (
	SEND_INTERVAL_MIN    = 20    /* ms between frames */
	SEND_INTERVAL_MAX    = 250   /* ms between frames */
	ACK_INTERVAL         = 3000  /* ms between empty acks */
	ACK_DELAY            = 100   /* ms before delayed ack */
	SHUTDOWN_RETRIES     = 16    /* number of shutdown packets to send before giving up */
	ACTIVE_RETRY_TIMEOUT = 10000 /* attempt to resend at frame rate */
)
View Source
const (
	SRTT_TRIGGER_LOW          = 20   // <= ms cures SRTT trigger to show predictions
	SRTT_TRIGGER_HIGH         = 30   // > ms starts SRTT trigger
	FLAG_TRIGGER_LOW          = 50   // <= ms cures flagging
	FLAG_TRIGGER_HIGH         = 80   // > ms starts flagging
	GLITCH_THRESHOLD          = 250  // prediction outstanding this long is glitch
	GLITCH_REPAIR_COUNT       = 10   // non-glitches required to cure glitch trigger
	GLITCH_REPAIR_MININTERVAL = 150  // required time in between non-glitches
	GLITCH_FLAG_THRESHOLD     = 5000 // prediction outstanding this long => underline
)
View Source
const (
	MAX_SIGNAL_NUMBER = 64
)

Variables

View Source
var (
	GitTag      string // build version
	GoVersion   string // Go version
	BuildTime   string // build time
	GitCommit   string // git commit id
	GitBranch   string // git branch name
	DefaultPort = 8100 // https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers
)

Functions

func PrintUsage

func PrintUsage(hint string, usage ...string)

func PrintVersion

func PrintVersion()

func ReadFromFile

func ReadFromFile(timeout int, msgChan chan Message, doneChan chan any, fReader io.Reader)

Read from the reader, set read time out for every read. The read result will be sent to caller via msgChan, including error info if available. doneChan channel is used to stop the file reader.

Note the caller should consume the last read message when shutdown.

func ReadFromNetwork

func ReadFromNetwork(timeout int, msgChan chan Message, doneChan chan any, connection Connection)

Read from the network, set read time out before every read. The read result will be sent to caller via msgChan, including error info if available. doneChan channel is used to stop the network receiver.

Note the caller should consume the last read message when shutdown. connection closed error will stop the function.

Types

type Connection

type Connection interface {
	Recv(timeout int) (payload string, rAddr net.Addr, err error)
}

for easy mock

type DisplayPreference

type DisplayPreference uint
const (
	DisplayPreferenceUnused DisplayPreference = iota
	Always
	Never
	Adaptive
	Experimental
)

type Message

type Message struct {
	Data  string   // payload data
	RAddr net.Addr // if the message is from network, it's the remote address
	Err   error    // error if it happens
}

communication the read result with the others

type NotificationEngine

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

represent the prediction notifications

func (*NotificationEngine) ClearNetworkError

func (ne *NotificationEngine) ClearNetworkError()

func (*NotificationEngine) GetNotificationString

func (ne *NotificationEngine) GetNotificationString() string

func (*NotificationEngine) ServerAcked

func (ne *NotificationEngine) ServerAcked(ts int64)

func (*NotificationEngine) ServerHeard

func (ne *NotificationEngine) ServerHeard(ts int64)

func (*NotificationEngine) SetEscapeKeyString

func (ne *NotificationEngine) SetEscapeKeyString(str string)

func (*NotificationEngine) SetNetworkError

func (ne *NotificationEngine) SetNetworkError(str string)

func (*NotificationEngine) SetNotificationString

func (ne *NotificationEngine) SetNotificationString(message string, permanent bool, showQuitKeystroke bool)

default parameters: permanent = false, showQuitKeystroke = true

type OverlayManager

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

func NewOverlayManager

func NewOverlayManager() *OverlayManager

func (*OverlayManager) Apply

func (om *OverlayManager) Apply(emu *terminal.Emulator)

func (*OverlayManager) GetNotificationEngine

func (om *OverlayManager) GetNotificationEngine() *NotificationEngine

func (*OverlayManager) GetPredictionEngine

func (om *OverlayManager) GetPredictionEngine() *PredictionEngine

func (*OverlayManager) SetTitlePrefix

func (om *OverlayManager) SetTitlePrefix(v string)

func (*OverlayManager) WaitTime

func (om *OverlayManager) WaitTime() int

type PredictionEngine

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

represent the prediction engine, which contains prediction cursor movement and prediction rows and cells.

func (*PredictionEngine) NewUserInput

func (pe *PredictionEngine) NewUserInput(emu *terminal.Emulator, input []rune)

process user input to prepare local prediction:cells and cursors. before process the input, PredictionEngine calls cull() method to check the prediction validity. a.k.a mosh new_user_byte() method

func (*PredictionEngine) Reset

func (pe *PredictionEngine) Reset()

clean all the cursor predictions and all the cell predictions. increase the epoch.

func (*PredictionEngine) SetDisplayPreference

func (pe *PredictionEngine) SetDisplayPreference(v DisplayPreference)

func (*PredictionEngine) SetLocalFrameAcked

func (pe *PredictionEngine) SetLocalFrameAcked(v uint64)

func (*PredictionEngine) SetLocalFrameLateAcked

func (pe *PredictionEngine) SetLocalFrameLateAcked(v uint64)

func (*PredictionEngine) SetLocalFrameSent

func (pe *PredictionEngine) SetLocalFrameSent(v uint64)

func (*PredictionEngine) SetPredictOverwrite

func (pe *PredictionEngine) SetPredictOverwrite(overwrite bool)

func (*PredictionEngine) SetSendInterval

func (pe *PredictionEngine) SetSendInterval(value uint)

type Signals

func (*Signals) AnySignal

func (s *Signals) AnySignal() (rv bool)

Check whether we got any signal. This method DOES NOT consumes any signal notification.

func (*Signals) Clear

func (s *Signals) Clear()

clear all the signals

func (*Signals) GotSignal

func (s *Signals) GotSignal(x syscall.Signal) (ret bool)

Check whether we got the spcified signal. If so return true, otherwise false. This method consumes a signal notification.

func (*Signals) Handler

func (s *Signals) Handler(signal os.Signal)

handle the signal by store it in Signals array.

type TitleEngine

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

represent the prediction title prefix.

type Validity

type Validity uint
const (
	ValidityUnused Validity = iota
	Pending
	Correct
	CorrectNoCredit
	IncorrectOrExpired
	Inactive
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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