Rename kgp_client to kgpdemux

Start keepalive
3 files changed, 14 insertions(+), 5 deletions(-)

M cmd/kgp_client/main.go => cmd/kgpdemux/main.go
M kgp.go
M kgp_test.go
M cmd/kgp_client/main.go => cmd/kgpdemux/main.go +0 -0

M kgp.go +14 -3
@@ 4,6 4,7 @@ 
 package kgp
 
 import (
+	"time"
 	"bytes"
 	"context"
 	"encoding/binary"

          
@@ 135,6 136,17 @@ type Demux struct {
 	RxSize int
 	TxSize int
 
+	// Time between keepalive packets, 0 == no keepalive
+	Keepalive time.Duration
+	// Where to write keepalive timings format:
+	//
+	// 		keepalive 1234ms
+	//
+	// or
+	//
+	// 		keepalive timeout
+	KeepaliveWriter io.Writer
+
 	Logger *log.Logger
 
 	server  io.ReadWriter

          
@@ 282,7 294,6 @@ func (demux *Demux) readServer(
 				return
 			}
 			ack.Store(p.header.Sequence)
-			fmt.Println(ack.Load())
 			demux.rxBytes += p.Size()
 			demux.rxPackets += 1
 			// Send the new packet to output and check if we're done

          
@@ 353,7 364,7 @@ func (demux *Demux) writeServer(
 	return input
 }
 
-func keepAlive(
+func keepaliveReply(
 	done func() <-chan struct{},
 	p *Packet,
 	output chan<- *Packet,

          
@@ 427,7 438,7 @@ func (demux *Demux) Run(ctx context.Cont
 			}
 			switch p.Type() {
 			case keepalivePacket:
-				go keepAlive(done, p, output)
+				go keepaliveReply(done, p, output)
 			case closePacket:
 				if bytes.Equal(p.Payload, []byte{'r'}) {
 					// half-close, we'll no longer receive data from the server

          
M kgp_test.go +0 -2
@@ 1,8 1,6 @@ 
 package kgp
 
 import (
-	"log"
-	"os"
 	"bytes"
 	"context"
 	"io"