aboutsummaryrefslogtreecommitdiff
path: root/process.go
diff options
context:
space:
mode:
authorHimbeer <himbeer@disroot.org>2024-12-07 11:21:06 +0100
committerHimbeer <himbeer@disroot.org>2024-12-07 11:24:27 +0100
commitaee7c77cb835299f7e0a96bc971a182619f91296 (patch)
treebe362af900bf5a3954f1684c4b65233716b61685 /process.go
parent162faad9f636263cc27413358af18de725db66d9 (diff)
Implement modchannel plugin API between proxy and servers (per-client)
Diffstat (limited to 'process.go')
-rw-r--r--process.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/process.go b/process.go
index 05b16fe..1d8263f 100644
--- a/process.go
+++ b/process.go
@@ -902,17 +902,54 @@ func (sc *ServerConn) process(pkt mt.Pkt) {
}
sc.prependInv(cmd.Changed[k].Inv)
}
+ case *mt.ToCltModChanMsg:
+ if handleSrvModChanMsg(clt, cmd) {
+ return
+ }
case *mt.ToCltModChanSig:
+ reportStatus := func(ch chan bool, status bool) {
+ ch <- status
+ delete(sc.modChanJoinChs[cmd.Channel], ch)
+ }
+
switch cmd.Signal {
case mt.JoinOK:
+ sc.modChanJoinChMu.Lock()
+ defer sc.modChanJoinChMu.Unlock()
+
+ for ch := range sc.modChanJoinChs[cmd.Channel] {
+ go reportStatus(ch, true)
+ }
+
if _, ok := clt.modChs[cmd.Channel]; ok {
return
}
clt.modChs[cmd.Channel] = struct{}{}
case mt.JoinFail:
+ sc.modChanJoinChMu.Lock()
+ defer sc.modChanJoinChMu.Unlock()
+
+ for ch := range sc.modChanJoinChs[cmd.Channel] {
+ go reportStatus(ch, false)
+ }
+
fallthrough
case mt.LeaveOK:
+ sc.modChanLeaveChMu.Lock()
+ defer sc.modChanLeaveChMu.Unlock()
+
+ for ch := range sc.modChanLeaveChs[cmd.Channel] {
+ go reportStatus(ch, true)
+ }
+
delete(clt.modChs, cmd.Channel)
+ case mt.LeaveFail:
+ sc.modChanLeaveChMu.Lock()
+ defer sc.modChanLeaveChMu.Unlock()
+
+ for ch := range sc.modChanLeaveChs[cmd.Channel] {
+ go reportStatus(ch, false)
+ }
}
}