Documentation ¶
Index ¶
- Constants
- Variables
- func DecodeTerminalCaps(str []byte) (map[int]string, error)
- func EncodeTerminalCaps(caps map[int]string) []byte
- func PrintUsage(hint string, usage ...string)
- func PrintVersion()
- func ReadFromFile(timeout int, msgChan chan Message, doneChan chan any, fReader io.Reader)
- func ReadFromNetwork(timeout int, msgChan chan Message, doneChan chan any, connection Connection)
- type Connection
- type DisplayPreference
- type Message
- type NotificationEngine
- func (ne *NotificationEngine) ClearNetworkError()
- func (ne *NotificationEngine) GetNotificationString() string
- func (ne *NotificationEngine) ServerAcked(ts int64)
- func (ne *NotificationEngine) ServerHeard(ts int64)
- func (ne *NotificationEngine) SetEscapeKeyString(str string)
- func (ne *NotificationEngine) SetNetworkError(str string)
- func (ne *NotificationEngine) SetNotificationString(message string, permanent bool, showQuitKeystroke bool)
- type OverlayManager
- type PredictionEngine
- func (pe *PredictionEngine) ClearApplied()
- func (pe *PredictionEngine) GetApplied() string
- func (pe *PredictionEngine) IsApplied() bool
- func (pe *PredictionEngine) NewUserInput(emu *terminal.Emulator, input []rune, ptime ...int64)
- func (pe *PredictionEngine) Reset()
- func (pe *PredictionEngine) SetDisplayPreference(v DisplayPreference)
- func (pe *PredictionEngine) SetLocalFrameAcked(v uint64)
- func (pe *PredictionEngine) SetLocalFrameLateAcked(v uint64)
- func (pe *PredictionEngine) SetLocalFrameSent(v uint64)
- func (pe *PredictionEngine) SetPredictOverwrite(overwrite bool)
- func (pe *PredictionEngine) SetSendInterval(value uint)
- type Signals
- type TitleEngine
- type Validity
Constants ¶
const ( AprilshMsgOpen = "open aprilsh:" AprishMsgClose = "close aprilsh:" AprilshPackageName = "aprilsh" CommandServerName = "apshd" CommandClientName = "apsh" TimeoutIfNoResp = 60000 TimeoutIfNoConnect = 15000 VersionInfo = `` /* 283-byte string literal not displayed */ )
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 */ )
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 )
const (
MAX_SIGNAL_NUMBER = 64
)
Variables ¶
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 EncodeTerminalCaps ¶
func PrintUsage ¶
func PrintVersion ¶
func PrintVersion()
func ReadFromFile ¶
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 ¶
for easy mock
type DisplayPreference ¶
type DisplayPreference uint
const ( DisplayPreferenceUnused DisplayPreference = iota Always Never // disable the prediction Adaptive Experimental )
type Message ¶
type Message struct { RAddr net.Addr // if the message is from network, it's the remote address Err error // error if it happens Data string // payload data }
communication the read result with the others
type NotificationEngine ¶
type NotificationEngine struct {
// contains filtered or unexported fields
}
func (*NotificationEngine) ClearNetworkError ¶
func (ne *NotificationEngine) ClearNetworkError()
extend message expire time 1 second later, if it's network message error.
func (*NotificationEngine) GetNotificationString ¶
func (ne *NotificationEngine) GetNotificationString() string
func (*NotificationEngine) ServerAcked ¶
func (ne *NotificationEngine) ServerAcked(ts int64)
set first sent state timestamp, when network input happens
func (*NotificationEngine) ServerHeard ¶
func (ne *NotificationEngine) ServerHeard(ts int64)
set latest received state timestamp, when network input happens or shutdown
func (*NotificationEngine) SetEscapeKeyString ¶
func (ne *NotificationEngine) SetEscapeKeyString(str string)
func (*NotificationEngine) SetNetworkError ¶
func (ne *NotificationEngine) SetNetworkError(str string)
set (network error) message and message expire time, message expires 3.1 seconds later.
func (*NotificationEngine) SetNotificationString ¶
func (ne *NotificationEngine) SetNotificationString(message string, permanent bool, showQuitKeystroke bool)
set message and message expire time, if permanent is true, message expire time is forever. if permanent is false, message expires 1 second later. also set showQuitKeystroke.
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
}
predict cursor movement and user input
func (*PredictionEngine) ClearApplied ¶
func (pe *PredictionEngine) ClearApplied()
func (*PredictionEngine) GetApplied ¶
func (pe *PredictionEngine) GetApplied() string
func (*PredictionEngine) IsApplied ¶
func (pe *PredictionEngine) IsApplied() bool
func (*PredictionEngine) NewUserInput ¶
func (pe *PredictionEngine) NewUserInput(emu *terminal.Emulator, input []rune, ptime ...int64)
when user input happens, set last sent state number before callling this method, this method validate previous predictions (cull), then use new input to prepare for new prediction. prepare for new prediction means updating prediction overlays, which involve cells and cursors.
a.k.a mosh new_user_byte() method
func (*PredictionEngine) Reset ¶
func (pe *PredictionEngine) Reset()
clear the whole predictions, start new epoch.
func (*PredictionEngine) SetDisplayPreference ¶
func (pe *PredictionEngine) SetDisplayPreference(v DisplayPreference)
set displayPreference when init
func (*PredictionEngine) SetLocalFrameAcked ¶
func (pe *PredictionEngine) SetLocalFrameAcked(v uint64)
when network input happens, set first sent state num
func (*PredictionEngine) SetLocalFrameLateAcked ¶
func (pe *PredictionEngine) SetLocalFrameLateAcked(v uint64)
when network input happens, set last received remote state acked num
func (*PredictionEngine) SetLocalFrameSent ¶
func (pe *PredictionEngine) SetLocalFrameSent(v uint64)
when user input happens, set last sent state num
func (*PredictionEngine) SetPredictOverwrite ¶
func (pe *PredictionEngine) SetPredictOverwrite(overwrite bool)
set predictOverwrite when init.
func (*PredictionEngine) SetSendInterval ¶
func (pe *PredictionEngine) SetSendInterval(value uint)
when network input happens, set send interval
type Signals ¶
type Signals [MAX_SIGNAL_NUMBER]atomic.Int32
func (*Signals) AnySignal ¶
Check whether we got any signal. This method DOES NOT consumes any signal notification.
type TitleEngine ¶
type TitleEngine struct {
// contains filtered or unexported fields
}
represent the prediction title prefix.