Files
xTeVe/src/struct-webserver.go
T
nathan 3a3ba861dc
continuous-integration/drone/push Build encountered an error
Phase 5a: persistent websocket with request ids and reconnect
Client (ts/network_ts.ts): one WebSocket per page. Commands queue and go
out one at a time with a client-chosen id; the response is matched on the
echoed id (or to the in-flight request for older servers). 12 s timeout
per request, exponential-backoff reconnect (0.5 s to 10 s), the in-flight
request is retried after a reconnect, and log polls are de-duplicated so
they cannot pile up behind a stalled connection. The old global flag that
silently dropped any request made while another was in flight is gone.

Server (src/webserver.go): the /data/ handler now serves any number of
commands on one connection (it used to break out of its loop after the
first reply without closing the socket, leaving it open and deaf; the old
client papered over that by opening a new socket per request). Connection
closed on exit, request id echoed in the response.

Test: TestWSServesMultipleCommandsPerConnection.
2026-09-26 13:19:38 +10:00

162 lines
6.2 KiB
Go

package src
// RequestStruct : Anfragen über die Websocket Schnittstelle
type RequestStruct struct {
// Befehle an xTeVe
Cmd string `json:"cmd"`
// Client-chosen request id, echoed in the response so the web UI can
// match answers on a long-lived connection.
ID string `json:"id,omitempty"`
// Benutzer
DeleteUser bool `json:"deleteUser,omitempty"`
UserData map[string]any `json:"userData,omitempty"`
// Mapping
EpgMapping map[string]any `json:"epgMapping,omitempty"`
// Restore
Base64 string `json:"base64,omitempty"`
// Neue Werte für die Einstellungen (settings.json)
Settings struct {
API *bool `json:"api,omitempty"`
UsePlexAPI *bool `json:"use_plexAPI,omitempty"`
PlexURL *string `json:"plex.url,omitempty"`
PlexToken *string `json:"plex.token,omitempty"`
AuthenticationAPI *bool `json:"authentication.api,omitempty"`
AuthenticationM3U *bool `json:"authentication.m3u,omitempty"`
AuthenticationPMS *bool `json:"authentication.pms,omitempty"`
AuthenticationWEP *bool `json:"authentication.web,omitempty"`
AuthenticationXML *bool `json:"authentication.xml,omitempty"`
BackupKeep *int `json:"backup.keep,omitempty"`
BackupPath *string `json:"backup.path,omitempty"`
Buffer *string `json:"buffer,omitempty"`
BufferSize *int `json:"buffer.size.kb,omitempty"`
BufferTimeout *float64 `json:"buffer.timeout,omitempty"`
CacheImages *bool `json:"cache.images,omitempty"`
EpgSource *string `json:"epgSource,omitempty"`
FFmpegOptions *string `json:"ffmpeg.options,omitempty"`
FFmpegPath *string `json:"ffmpeg.path,omitempty"`
VLCOptions *string `json:"vlc.options,omitempty"`
VLCPath *string `json:"vlc.path,omitempty"`
FilesUpdate *bool `json:"files.update,omitempty"`
TempPath *string `json:"temp.path,omitempty"`
Tuner *int `json:"tuner,omitempty"`
UDPxy *string `json:"udpxy,omitempty"`
Update *[]string `json:"update,omitempty"`
UserAgent *string `json:"user.agent,omitempty"`
XepgMissingEPGMode *string `json:"xepg.missing.epg.mode,omitempty"`
XepgReplaceMissingImages *bool `json:"xepg.replace.missing.images,omitempty"`
SchemeM3U *string `json:"scheme.m3u,omitempty"`
SchemeXML *string `json:"scheme.xml,omitempty"`
} `json:"settings"`
// Upload Logo
Filename string `json:"filename,omitempty"`
// Filter
Filter map[int64]any `json:"filter,omitempty"`
// Dateien (M3U, HDHR, XMLTV)
Files struct {
HDHR map[string]any `json:"hdhr,omitempty"`
M3U map[string]any `json:"m3u,omitempty"`
XMLTV map[string]any `json:"xmltv,omitempty"`
} `json:"files"`
// Wizard
Wizard struct {
EpgSource *string `json:"epgSource,omitempty"`
M3U *string `json:"m3u,omitempty"`
Tuner *int `json:"tuner,omitempty"`
XMLTV *string `json:"xmltv,omitempty"`
} `json:"wizard"`
}
// ResponseStruct : Antworten an den Client (WEB)
type ResponseStruct struct {
ID string `json:"id,omitempty"`
ClientInfo struct {
ARCH string `json:"arch"`
Branch string `json:"branch,omitempty"`
DVR string `json:"DVR"`
EpgSource string `json:"epgSource"`
Errors int `json:"errors"`
M3U string `json:"m3u-url"`
OS string `json:"os"`
Streams string `json:"streams"`
UUID string `json:"uuid"`
Version string `json:"version"`
Warnings int `json:"warnings"`
XEPGCount int64 `json:"xepg"`
XML string `json:"xepg-url"`
} `json:"clientInfo"`
Data struct {
Playlist struct {
M3U struct {
Groups struct {
Text []string `json:"text"`
Value []string `json:"value"`
} `json:"groups"`
} `json:"m3u"`
} `json:"playlist"`
StreamPreviewUI struct {
Active []string `json:"activeStreams"`
Inactive []string `json:"inactiveStreams"`
}
} `json:"data"`
Alert string `json:"alert,omitempty"`
ConfigurationWizard bool `json:"configurationWizard"`
Error string `json:"err,omitempty"`
Log WebScreenLogStruct `json:"log"`
LogoURL string `json:"logoURL,omitempty"`
OpenLink string `json:"openLink,omitempty"`
OpenMenu string `json:"openMenu,omitempty"`
Reload bool `json:"reload,omitempty"`
Settings SettingsStruct `json:"settings"`
Status bool `json:"status"`
Token string `json:"token,omitempty"`
Users map[string]any `json:"users,omitempty"`
Wizard int `json:"wizard,omitempty"`
XEPG map[string]any `json:"xepg"`
Notification map[string]Notification `json:"notification,omitempty"`
}
// APIRequestStruct : Anfrage über die API Schnittstelle
type APIRequestStruct struct {
Cmd string `json:"cmd"`
Password string `json:"password"`
Token string `json:"token"`
Username string `json:"username"`
}
// APIResponseStruct : Antwort an den Client (API)
type APIResponseStruct struct {
EpgSource string `json:"epg.source,omitempty"`
Error string `json:"err,omitempty"`
Status bool `json:"status"`
StreamsActive int64 `json:"streams.active,omitempty"`
StreamsAll int64 `json:"streams.all,omitempty"`
StreamsXepg int64 `json:"streams.xepg,omitempty"`
Token string `json:"token,omitempty"`
URLDvr string `json:"url.dvr,omitempty"`
URLM3U string `json:"url.m3u,omitempty"`
URLXepg string `json:"url.xepg,omitempty"`
VersionAPI string `json:"version.api,omitempty"`
VersionXteve string `json:"version.xteve,omitempty"`
}
// WebScreenLogStruct : Logs werden im RAM gespeichert und für das Webinterface bereitgestellt
type WebScreenLogStruct struct {
Errors int `json:"errors"`
Log []string `json:"log"`
Warnings int `json:"warnings"`
}