Join WebSocket contexts on reconnect

This commit is contained in:
Elara 2022-12-12 18:40:55 -08:00
parent 27c94b7d21
commit 5d53167775
3 changed files with 17 additions and 12 deletions

2
go.mod
View File

@ -8,7 +8,7 @@ require (
github.com/pelletier/go-toml/v2 v2.0.6
github.com/spf13/pflag v1.0.5
github.com/vmihailenco/msgpack/v5 v5.3.5
go.arsenm.dev/go-lemmy v0.0.0-20221213021222-a4a015a4cc2a
go.arsenm.dev/go-lemmy v0.0.0-20221213023656-b38c6b0a5455
go.arsenm.dev/logger v0.0.0-20221007032343-cbffce4f4334
go.arsenm.dev/pcre v0.0.0-20220530205550-74594f6c8b0e
)

4
go.sum
View File

@ -45,8 +45,8 @@ github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8=
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
go.arsenm.dev/go-lemmy v0.0.0-20221213021222-a4a015a4cc2a h1:iBeRt2sU8Y3pwKPKTFnkIcTwFTvifyCLUtjjsj7CaWM=
go.arsenm.dev/go-lemmy v0.0.0-20221213021222-a4a015a4cc2a/go.mod h1:/XgX+cQqs9a2VJWwZ67wArjK2CVXWKdEEpHdAFbFRNQ=
go.arsenm.dev/go-lemmy v0.0.0-20221213023656-b38c6b0a5455 h1:AUeVhWSB6Wzz6TDiMSi6TGrzXyPGg3flXdASs+42vTA=
go.arsenm.dev/go-lemmy v0.0.0-20221213023656-b38c6b0a5455/go.mod h1:hLkcWy1iV2PlzZZVWjuV3Y3hMynM0k8g9Ul94CcusUM=
go.arsenm.dev/logger v0.0.0-20221007032343-cbffce4f4334 h1:S98LJOBmj1pAKSw94spJk6+n8ERlBNTxi4lt5B67nQo=
go.arsenm.dev/logger v0.0.0-20221007032343-cbffce4f4334/go.mod h1:RV2qydKDdoyaRkhAq8JEGvojR8eJ6bjq5WnSIlH7gYw=
go.arsenm.dev/pcre v0.0.0-20220530205550-74594f6c8b0e h1:4XwLmFDvAKt7ZvS3E3hD2R++0wr75fBUEvXkK9dLXzk=

View File

@ -45,6 +45,7 @@ func main() {
log.Info("Successfully logged in to Lemmy instance").Send()
c.SetConnectHandler(func() error {
err = c.Request(types.UserOpUserJoin, nil)
if err != nil {
log.Fatal("Error joining WebSocket user context").Err(err).Send()
@ -56,6 +57,10 @@ func main() {
if err != nil {
log.Fatal("Error joining WebSocket community context").Err(err).Send()
}
return nil
})
c.ConnectHandler()
replyCh := make(chan replyJob, 200)