Documentation
¶
Overview ¶
Package session is the desktop app's connection to notesd (docs/design/app.md#data, plan 0009): it dials the private socket as the local caller, says hello, subscribes to events from the sequence it last saw, dials again each second when the connection drops, and keeps the open notes' documents, to which it routes note.changed, note.moved and note.removed. It imports no UI: the window gives it an Env that runs work on its thread.
Index ¶
- Constants
- type Dialer
- type Session
- func (s *Session) Client() *api.Client
- func (s *Session) Close()
- func (s *Session) Flush(done func())
- func (s *Session) Hello() *api.Hello
- func (s *Session) Notes() notes.NoteAPI
- func (s *Session) OnChange(fn func())
- func (s *Session) Open(vault int64, path string) *notes.Document
- func (s *Session) Reason() string
- func (s *Session) Release(d *notes.Document)
- func (s *Session) Seq() int64
- func (s *Session) Start()
- func (s *Session) State() State
- func (s *Session) Under(vault int64, p string) []*notes.Document
- func (s *Session) Unsaved() bool
- type State
Constants ¶
const ClientName = "Frostnotes"
ClientName is what the app tells notesd in rpc.hello, and the author of its versions.
const RetryDelay = time.Second
RetryDelay is how long the session waits before it dials again, as the web app's.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dialer ¶
Dialer connects to notesd and completes rpc.hello.
func SocketDialer ¶
SocketDialer dials notesd's socket at path.
type Session ¶
type Session struct {
// OnEvent sees every event after the session has routed note events
// to the open documents: the stores follow vaults, files and sync.
OnEvent func(seq int64, ev api.Event)
// OnResync is called when notesd could not replay the events since
// the stored sequence: the stores read everything again.
OnResync func()
// OnSeq is called with each new event sequence, for the app to keep
// as its resume point (ADR-0021).
OnSeq func(seq int64)
// contains filtered or unexported fields
}
Session is the app's connection to notesd. Its methods run on the UI thread.
func New ¶
New makes a session that resumes events after seq (0 for live events only). Start connects it.
func (*Session) Flush ¶
func (s *Session) Flush(done func())
Flush saves every open note and calls done once none has text unsaved (or a failed save waits to retry).
func (*Session) OnChange ¶
func (s *Session) OnChange(fn func())
OnChange calls fn on the UI thread when the state changes.
func (*Session) Open ¶
Open returns the document of a note, shared by every tab that shows it, reading it the first time. Release gives it back.
func (*Session) Release ¶
Release gives back a document Open returned; the last release saves what is unsaved, then forgets it. A save that failed keeps the document until a retry lands it, so closing a tab loses no text.
func (*Session) Start ¶
func (s *Session) Start()
Start connects, and connects again whenever the connection drops, until Close.