From fa137553111d51327037ed44e2b9ab513696b230 Mon Sep 17 00:00:00 2001 From: mappu Date: Sat, 24 Mar 2018 13:22:34 +1300 Subject: [PATCH] libnmdc compatibility fixes (now requires 0.17++) --HG-- branch : nmdc-ircfrontend --- server.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/server.go b/server.go index df5d0f1..b7d5ac0 100644 --- a/server.go +++ b/server.go @@ -75,6 +75,7 @@ type Server struct { upstreamLauncher libnmdc.HubConnectionOptions upstreamCloser chan struct{} + upstreamEvents chan libnmdc.HubEvent upstream *libnmdc.HubConnection verbose bool @@ -99,9 +100,10 @@ func NewServer(name string, upstream libnmdc.HubAddress, conn net.Conn) *Server motd: "Connected to " + name + ". You /must/ join " + BLESSED_CHANNEL + " to continue.", upstreamLauncher: libnmdc.HubConnectionOptions{ Address: upstream, - Self: *self, + Self: self, SkipAutoReconnect: true, }, + upstreamEvents: make(chan libnmdc.HubEvent, 0), // unbuffered upstreamCloser: make(chan struct{}, 1), quirks: DefaultQuirks(), } @@ -255,7 +257,7 @@ func (s *Server) upstreamWorker() { s.upstream.Disconnect() return - case hubEvent := <-s.upstream.OnEvent: + case hubEvent := <-s.upstreamEvents: switch hubEvent.EventType { case libnmdc.EVENT_USER_JOINED: s.reply(rplJoin, hubEvent.Nick, BLESSED_CHANNEL) @@ -537,7 +539,7 @@ func (s *Server) maybeStartUpstream() { s.reply(rplJoin, s.clientNick(), BLESSED_CHANNEL) // Spawn upstream connection - s.upstream = s.upstreamLauncher.Connect() + s.upstream = libnmdc.ConnectAsync(&s.upstreamLauncher, s.upstreamEvents) go s.upstreamWorker() } else {