MCPcopy Index your code
hub / github.com/koding/kite / sendHub

Method sendHub

client.go:572–607  ·  view source on GitHub ↗

sendhub sends the msg received from the send channel to the remote client

()

Source from the content-addressed store, hash-verified

570
571// sendhub sends the msg received from the send channel to the remote client
572func (c *Client) sendHub() {
573 defer c.wg.Done()
574
575 for {
576 select {
577 case msg := <-c.send:
578 c.LocalKite.Log.Debug("sending: %s", msg)
579 session := c.getSession()
580 if session == nil {
581 c.LocalKite.Log.Error("not connected")
582 continue
583 }
584
585 err := session.Send(string(msg.p))
586 if err != nil {
587 if msg.errC != nil {
588 msg.errC <- err
589 }
590
591 if sockjsclient.IsSessionClosed(err) {
592 // The readloop may already be interrupted, thus the non-blocking send.
593 select {
594 case c.interrupt <- err:
595 default:
596 }
597
598 c.LocalKite.Log.Error("error sending to %s: %s", session.ID(), err)
599 return
600 }
601 }
602 case <-c.closeChan:
603 c.LocalKite.Log.Debug("Send hub is closed")
604 return
605 }
606 }
607}
608
609// OnConnect adds a callback which is called when client connects
610// to a remote kite.

Callers 2

sockjsHandlerMethod · 0.95
dialMethod · 0.95

Calls 5

getSessionMethod · 0.95
DebugMethod · 0.80
ErrorMethod · 0.65
SendMethod · 0.45
IDMethod · 0.45

Tested by

no test coverage detected