existential fixes for the synchronous API

This commit is contained in:
mappu 2016-11-29 19:39:47 +13:00
parent 231bfeb247
commit 482b0d3ad8

View File

@ -11,7 +11,7 @@ type HubConnectionOptions struct {
NumEventsToBuffer uint NumEventsToBuffer uint
// Returning messages in sync mode // Returning messages in sync mode
OnEventSync func(HubEvent) OnEventSync func(*HubConnection, HubEvent)
} }
func (this *HubConnectionOptions) prepareConnection() *HubConnection { func (this *HubConnectionOptions) prepareConnection() *HubConnection {
@ -54,5 +54,9 @@ func (this *HubConnectionOptions) Connect() *HubConnection {
// Client code should supply an event handling function as hco.OnEventSync. // Client code should supply an event handling function as hco.OnEventSync.
func (this *HubConnectionOptions) ConnectSync() { func (this *HubConnectionOptions) ConnectSync() {
hc := this.prepareConnection() hc := this.prepareConnection()
hc.OnEvent = nil
hc.processEvent = func(ev HubEvent) {
this.OnEventSync(hc, ev)
}
hc.worker() hc.worker()
} }