|
|
@ -16,7 +16,6 @@ type Client struct {
|
|
|
|
Host string
|
|
|
|
Host string
|
|
|
|
Port int
|
|
|
|
Port int
|
|
|
|
|
|
|
|
|
|
|
|
lastSeq int
|
|
|
|
|
|
|
|
conn *websocket.Conn
|
|
|
|
conn *websocket.Conn
|
|
|
|
|
|
|
|
|
|
|
|
outbox chan *pending
|
|
|
|
outbox chan *pending
|
|
|
@ -132,11 +131,10 @@ func (c *Client) readLoop(notifications chan<- Response) {
|
|
|
|
func (c *Client) writeLoop() {
|
|
|
|
func (c *Client) writeLoop() {
|
|
|
|
sent := make(map[int]*pending)
|
|
|
|
sent := make(map[int]*pending)
|
|
|
|
|
|
|
|
|
|
|
|
for {
|
|
|
|
for seq := 1; true; seq++ {
|
|
|
|
select {
|
|
|
|
select {
|
|
|
|
case p := <-c.outbox:
|
|
|
|
case p := <-c.outbox:
|
|
|
|
c.lastSeq++
|
|
|
|
req := Request{seq, p.v}
|
|
|
|
req := Request{c.lastSeq, p.v}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
w, err := c.conn.NextWriter(websocket.TextMessage)
|
|
|
|
w, err := c.conn.NextWriter(websocket.TextMessage)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
@ -161,7 +159,7 @@ func (c *Client) writeLoop() {
|
|
|
|
break
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
c.Child("write-frame").Info(string(b))
|
|
|
|
c.Child("write-frame").Info(string(b))
|
|
|
|
sent[c.lastSeq] = p
|
|
|
|
sent[seq] = p
|
|
|
|
|
|
|
|
|
|
|
|
case res := <-c.resolved:
|
|
|
|
case res := <-c.resolved:
|
|
|
|
p, ok := sent[res.Re]
|
|
|
|
p, ok := sent[res.Re]
|
|
|
|