From 74ce364daef175488c6531b150944a0320d3290f Mon Sep 17 00:00:00 2001
From: Matteo Suppo <matteo.suppo@gmail.com>
Date: Wed, 14 Oct 2015 12:14:41 +0200
Subject: [PATCH] Don't send messages if there is nothing to send

---
 bufferflow_timed.go | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/bufferflow_timed.go b/bufferflow_timed.go
index 6dd58dfa4..3ce3b6a85 100644
--- a/bufferflow_timed.go
+++ b/bufferflow_timed.go
@@ -2,8 +2,9 @@ package main
 
 import (
 	"encoding/json"
-	log "github.com/Sirupsen/logrus"
 	"time"
+
+	log "github.com/Sirupsen/logrus"
 )
 
 type BufferflowTimed struct {
@@ -31,10 +32,12 @@ func (b *BufferflowTimed) Init() {
 	go func() {
 		b.ticker = time.NewTicker(16 * time.Millisecond)
 		for _ = range b.ticker.C {
-			m := SpPortMessage{bufferedOutput}
-			buf, _ := json.Marshal(m)
-			b.Output <- []byte(buf)
-			bufferedOutput = ""
+			if bufferedOutput != "" {
+				m := SpPortMessage{bufferedOutput}
+				buf, _ := json.Marshal(m)
+				b.Output <- []byte(buf)
+				bufferedOutput = ""
+			}
 		}
 	}()