From 0c06142ae939a0813b706811291c8f90ee0bca30 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 6 Apr 2020 17:03:07 +0200 Subject: [PATCH] Introduce upstreamConn.produce The logic in this function is about to get more complicated. It'll soon also dispatch messages in connected downstreams. --- downstream.go | 2 +- upstream.go | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/downstream.go b/downstream.go index 11bf43d..9cb9b39 100644 --- a/downstream.go +++ b/downstream.go @@ -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 diff --git a/upstream.go b/upstream.go index d779979..3bb6747 100644 --- a/upstream.go +++ b/upstream.go @@ -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) {