Changeset 684 in code for trunk/user.go


Ignore:
Timestamp:
Nov 15, 2021, 1:34:04 PM (4 years ago)
Author:
contact
Message:

Add support for MONITOR

Add support for MONITOR in single-upstream mode.

Each downstream has its own set of monitored targets. These sets
are merged together to compute the MONITOR commands to send to
upstream.

Each upstream has a set of monitored targets accepted by the server
alongside with their status (online/offline). This is used to
directly send replies to downstreams adding a target another
downstream has already added, and send MONITOR S[TATUS] replies.

Co-authored-by: delthas <delthas@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/user.go

    r682 r684  
    343343        net.channels.SetCasemapping(newCasemap)
    344344        net.delivered.m.SetCasemapping(newCasemap)
    345         if net.conn != nil {
    346                 net.conn.channels.SetCasemapping(newCasemap)
    347                 for _, entry := range net.conn.channels.innerMap {
     345        if uc := net.conn; uc != nil {
     346                uc.channels.SetCasemapping(newCasemap)
     347                for _, entry := range uc.channels.innerMap {
    348348                        uch := entry.value.(*upstreamChannel)
    349349                        uch.Members.SetCasemapping(newCasemap)
    350350                }
    351         }
     351                uc.monitored.SetCasemapping(newCasemap)
     352        }
     353        net.forEachDownstream(func(dc *downstreamConn) {
     354                dc.monitored.SetCasemapping(newCasemap)
     355        })
    352356}
    353357
     
    520524
    521525                        uc.updateAway()
     526                        uc.updateMonitor()
    522527
    523528                        netIDStr := fmt.Sprintf("%v", uc.network.ID)
     
    589594                        dc := e.dc
    590595
     596                        if dc.network != nil {
     597                                dc.monitored.SetCasemapping(dc.network.casemap)
     598                        }
     599
    591600                        if err := dc.welcome(); err != nil {
    592601                                dc.logger.Printf("failed to handle new registered connection: %v", err)
     
    621630                        u.forEachUpstream(func(uc *upstreamConn) {
    622631                                uc.updateAway()
     632                                uc.updateMonitor()
    623633                        })
    624634                case eventDownstreamMessage:
Note: See TracChangeset for help on using the changeset viewer.