upgrade to support libnmdc v0.18.0

This commit is contained in:
mappu 2020-05-07 19:14:49 +12:00
parent beaf18eb8e
commit 6641d00247

11
main.go
View File

@ -60,13 +60,14 @@ func (this *HubWorker) MainLoop(addr, nick, password string) {
opts := libnmdc.HubConnectionOptions{ opts := libnmdc.HubConnectionOptions{
Address: libnmdc.HubAddress(addr), Address: libnmdc.HubAddress(addr),
SkipVerifyTLS: !VerifyTLS, SkipVerifyTLS: !VerifyTLS,
Self: *libnmdc.NewUserInfo(nick), Self: libnmdc.NewUserInfo(nick),
NickPassword: password, NickPassword: password,
} }
hub := opts.Connect()
for { evChan := make(chan libnmdc.HubEvent, 1)
event := <-hub.OnEvent hub := libnmdc.ConnectAsync(&opts, evChan)
for event := range evChan {
if DebugMode { if DebugMode {
fmt.Printf("DEBUG: %s %v\n", addr, event) fmt.Printf("DEBUG: %s %v\n", addr, event)
@ -75,7 +76,7 @@ func (this *HubWorker) MainLoop(addr, nick, password string) {
switch event.EventType { switch event.EventType {
case libnmdc.EVENT_CONNECTION_STATE_CHANGED: case libnmdc.EVENT_CONNECTION_STATE_CHANGED:
if LogConnectionState { if LogConnectionState {
str := "* " + event.StateChange.Format() str := "* " + event.StateChange.String()
if len(event.Message) > 0 { if len(event.Message) > 0 {
str += " (" + event.Message + ")" str += " (" + event.Message + ")"
} }