From 73f6d66cbd2883522b404640e62afa87d7ccccbd Mon Sep 17 00:00:00 2001 From: mappu Date: Sun, 3 Apr 2016 18:59:11 +1200 Subject: [PATCH] libnmdc: reinstate backward-compatibility re new sync api --- src/libnmdc/libnmdc.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/libnmdc/libnmdc.go b/src/libnmdc/libnmdc.go index 4a990b7..c9e2e2a 100644 --- a/src/libnmdc/libnmdc.go +++ b/src/libnmdc/libnmdc.go @@ -87,7 +87,6 @@ type HubConnectionOptions struct { // Returning messages in async mode NumEventsToBuffer uint - OnEvent chan HubEvent // Returning messages in sync mode OnEventSync func(HubEvent) @@ -104,6 +103,7 @@ type HubConnection struct { // Streamed events processEvent func(HubEvent) + OnEvent chan HubEvent // Private state conn net.Conn // this is an interface @@ -428,14 +428,11 @@ func (this *HubConnectionOptions) Connect() *HubConnection { if this.NumEventsToBuffer < 1 { this.NumEventsToBuffer = 1 } - if this.OnEvent == nil { - this.OnEvent = make(chan HubEvent, this.NumEventsToBuffer) - } hc := this.prepareConnection() - + hc.OnEvent = make(chan HubEvent, this.NumEventsToBuffer) hc.processEvent = func(ev HubEvent) { - this.OnEvent <- ev + hc.OnEvent <- ev } go hc.worker()