Compare commits
No commits in common. "master" and "v1.3.0" have entirely different histories.
1 changed files with 5 additions and 8 deletions
|
@ -33,7 +33,6 @@ type ZelloClient struct {
|
||||||
// Event Chans
|
// Event Chans
|
||||||
GeneralEventChan chan ZelloResponsePacked
|
GeneralEventChan chan ZelloResponsePacked
|
||||||
BinaryDataChan chan []byte
|
BinaryDataChan chan []byte
|
||||||
ErrorEventChan chan error
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewZelloClient() (zelloClient *ZelloClient) {
|
func NewZelloClient() (zelloClient *ZelloClient) {
|
||||||
|
@ -44,7 +43,6 @@ func NewZelloClient() (zelloClient *ZelloClient) {
|
||||||
DefaultTimeout: time.Millisecond * 1e3,
|
DefaultTimeout: time.Millisecond * 1e3,
|
||||||
SeqResponseChans: make(map[int64]chan map[string]interface{}),
|
SeqResponseChans: make(map[int64]chan map[string]interface{}),
|
||||||
GeneralEventChan: make(chan ZelloResponsePacked),
|
GeneralEventChan: make(chan ZelloResponsePacked),
|
||||||
ErrorEventChan: make(chan error),
|
|
||||||
BinaryDataChan: make(chan []byte),
|
BinaryDataChan: make(chan []byte),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -486,26 +484,25 @@ func (zc *ZelloClient) handleRXbinary(data []byte) (err error) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (zc *ZelloClient) Work() (err error) {
|
func (zc *ZelloClient) Work() {
|
||||||
for {
|
for {
|
||||||
msgType, message, err := zc.Connection.ReadMessage()
|
msgType, message, err := zc.Connection.ReadMessage()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//log.Println("read:", err)
|
log.Println("read:", err)
|
||||||
zc.ErrorEventChan <- err
|
return
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
if msgType == websocket.TextMessage {
|
if msgType == websocket.TextMessage {
|
||||||
err = zc.handleRXjson(message)
|
err = zc.handleRXjson(message)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("handleRXjson:", err)
|
log.Println("handleRXjson:", err)
|
||||||
return err
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if msgType == websocket.BinaryMessage {
|
if msgType == websocket.BinaryMessage {
|
||||||
err = zc.handleRXbinary(message)
|
err = zc.handleRXbinary(message)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("handleRXbinary:", err)
|
log.Println("handleRXbinary:", err)
|
||||||
return err
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue