libnmdc compatibility fixes (now requires 0.17++)

--HG--
branch : nmdc-ircfrontend
This commit is contained in:
mappu 2018-03-24 13:22:34 +13:00
parent e83e2dc111
commit fa13755311

View File

@ -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 {