Skip to content

Commit

Permalink
more client improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
felipejfc committed Apr 13, 2018
1 parent 424b71f commit b4c31a7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,12 @@ func (c *Client) readPackets(buf []byte) ([]*packet.Packet, error) {

func (c *Client) handleServerMessages() {
buf := make([]byte, 2048)
defer c.Disconnect()
for c.Connected {
packets, err := c.readPackets(buf)
if err != nil {
log.Fatal(err)
log.Error(err)
break
}

for _, p := range packets {
Expand Down Expand Up @@ -215,6 +217,7 @@ func (c *Client) sendHeartbeats(interval int) {

// Disconnect disconnects the client
func (c *Client) Disconnect() {
message.SetDictionary(map[string]uint16{})
c.Connected = false
close(c.closeChan)
c.conn.Close()
Expand Down

0 comments on commit b4c31a7

Please sign in to comment.