Introduce upstreamConn.produce

The logic in this function is about to get more complicated. It'll soon
also dispatch messages in connected downstreams.
This commit is contained in:
Simon Ser 2020-04-06 17:03:07 +02:00
parent 3680facb1d
commit 0c06142ae9
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
2 changed files with 8 additions and 4 deletions

View File

@ -1231,7 +1231,7 @@ func (dc *downstreamConn) handleMessageRegistered(msg *irc.Message) error {
uc.appendLog(upstreamName, echoMsg)
uc.network.ring.Produce(echoMsg)
uc.produce(echoMsg)
}
case "NOTICE":
var targetsStr, text string

View File

@ -247,7 +247,7 @@ func (uc *upstreamConn) handleMessage(msg *irc.Message) error {
return nil
case "NOTICE":
if msg.Prefix.User == "" && msg.Prefix.Host == "" { // server message
uc.network.ring.Produce(msg)
uc.produce(msg)
} else { // regular user NOTICE
var entity, text string
if err := parseMessageParams(msg, &entity, &text); err != nil {
@ -260,7 +260,7 @@ func (uc *upstreamConn) handleMessage(msg *irc.Message) error {
}
uc.appendLog(target, msg)
uc.network.ring.Produce(msg)
uc.produce(msg)
}
case "CAP":
var subCmd string
@ -1135,7 +1135,7 @@ func (uc *upstreamConn) handleMessage(msg *irc.Message) error {
}
uc.appendLog(target, msg)
uc.network.ring.Produce(msg)
uc.produce(msg)
case "INVITE":
var nick string
var channel string
@ -1363,6 +1363,10 @@ func (uc *upstreamConn) appendLog(entity string, msg *irc.Message) {
}
}
func (uc *upstreamConn) produce(msg *irc.Message) {
uc.network.ring.Produce(msg)
}
func (uc *upstreamConn) updateAway() {
away := true
uc.forEachDownstream(func(*downstreamConn) {