diff options
author | Himbeer <himbeer@disroot.org> | 2024-12-07 11:21:06 +0100 |
---|---|---|
committer | Himbeer <himbeer@disroot.org> | 2024-12-07 11:24:27 +0100 |
commit | aee7c77cb835299f7e0a96bc971a182619f91296 (patch) | |
tree | be362af900bf5a3954f1684c4b65233716b61685 /process.go | |
parent | 162faad9f636263cc27413358af18de725db66d9 (diff) |
Implement modchannel plugin API between proxy and servers (per-client)
Diffstat (limited to 'process.go')
-rw-r--r-- | process.go | 37 |
1 files changed, 37 insertions, 0 deletions
@@ -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) + } } } |