statesync

package
v0.0.0-...-87adcba Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ECHO_TIMEOUT = 50 // for late ack
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Complete

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

Complete implements network.State[C any] interface

func NewComplete

func NewComplete(nCols, nRows, saveLines int) (*Complete, error)

func (*Complete) Act

func (c *Complete) Act(str string) string

let the terminal parse and handle the data stream.

func (*Complete) ActLarge

func (c *Complete) ActLarge(str string, feed chan string) string

let the terminal parse and handle the data stream.

func (*Complete) ActOne

func (c *Complete) ActOne(x terminal.ActOn) string

run the action in terminal, return the contents in terminalToHost.

func (*Complete) ApplyString

func (c *Complete) ApplyString(diff string) error

implements network.State[C any] interface convert differene content into HostMessage, and apply the instructions to the terminal.

func (*Complete) Clone

func (c *Complete) Clone() *Complete

implements network.State[C any] interface

func (*Complete) DiffFrom

func (c *Complete) DiffFrom(existing *Complete) string

implements network.State[C any] interface compare two Complete value and build the seralized HostMessage: difference content.

func (*Complete) Equal

func (c *Complete) Equal(x *Complete) bool

implements network.State[C any] interface

func (*Complete) EqualTrace

func (c *Complete) EqualTrace(x *Complete) bool

fot test purpose implements network.State[C any] interface

func (*Complete) GetDiff

func (c *Complete) GetDiff() string

func (*Complete) GetEchoAck

func (c *Complete) GetEchoAck() uint64

func (*Complete) GetEmulator

func (c *Complete) GetEmulator() *terminal.Emulator

func (*Complete) InitDiff

func (c *Complete) InitDiff() string

implements network.State[C any] interface get difference between this Complete and a new one.

func (*Complete) InitSize

func (c *Complete) InitSize(nCols, nRows int)

func (*Complete) RegisterInputFrame

func (c *Complete) RegisterInputFrame(num uint64, now int64)

register the latest remote state number and time. the latest remote state is the client input state.

func (*Complete) Reset

func (c *Complete) Reset()

implements network.State[C any] interface

func (*Complete) ResetInput

func (c *Complete) ResetInput()

implements network.State[C any] interface

func (*Complete) SetEchoAck

func (c *Complete) SetEchoAck(now int64) (ret bool)

shrink input history according to timestamp. return true if newestEchoAck changed. update echoAck if find the newest state.

func (*Complete) Subtract

func (c *Complete) Subtract(prefix *Complete)

implements network.State[C any] interface

func (*Complete) WaitTime

func (c *Complete) WaitTime(now int64) int

return 0 if history frame state + 50ms < now. That means now is larger than 50ms. return max int if there is only one history frame. return normal gap between now and history frame + 50ms.

if the frame is not acked after ECHO_TIMEOUT, give short WaitTime to accelerate ack actions.

type UserEvent

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

UserByte instance is created by aprish client, when client got the user input. Resize instance is created by aprish client, when client change the window size.

func NewUserEvent

func NewUserEvent(userByte terminal.UserByte) (u UserEvent)

func NewUserEventResize

func NewUserEventResize(resize terminal.Resize) (u UserEvent)

type UserEventType

type UserEventType uint8
const (
	UserByteType UserEventType = iota
	ResizeType
)

type UserStream

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

UserStream implements network.State[C any] interface

func (*UserStream) ApplyString

func (u *UserStream) ApplyString(diff string) error

implements network.State[C any] interface convert the UserMessage into a UserStream

func (*UserStream) Clone

func (u *UserStream) Clone() *UserStream

implements network.State[C any] interface

func (*UserStream) DiffFrom

func (u *UserStream) DiffFrom(existing *UserStream) string

implements network.State[C any] interface DiffFrom() exclude the existing UserEvent and return the difference.

func (*UserStream) Empty

func (u *UserStream) Empty() bool

func (*UserStream) Equal

func (u *UserStream) Equal(x *UserStream) bool

implements network.State[C any] interface

func (*UserStream) EqualTrace

func (u *UserStream) EqualTrace(x *UserStream) bool

for test purpose

func (*UserStream) GetAction

func (u *UserStream) GetAction(i int) terminal.ActOn

func (*UserStream) InitDiff

func (u *UserStream) InitDiff() string

implements network.State[C any] interface

func (*UserStream) InitSize

func (u *UserStream) InitSize(nCols, nRows int)

func (*UserStream) PushBack

func (u *UserStream) PushBack(x []rune)

func (*UserStream) PushBackResize

func (u *UserStream) PushBackResize(width, height int)

func (*UserStream) Reset

func (u *UserStream) Reset()

func (*UserStream) ResetInput

func (u *UserStream) ResetInput()

implements network.State[C any] interface

func (*UserStream) Size

func (u *UserStream) Size() int

func (*UserStream) String

func (u *UserStream) String() string

func (*UserStream) Subtract

func (u *UserStream) Subtract(prefix *UserStream)

implements network.State[C any] interface Subtract() the prefix UserStream from current UserStream

Jump to

Keyboard shortcuts

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