func (c *chatRemoton) start(session *remoton.SessionClient) { l := session.Listen("chat") for { wsconn, err := l.Accept() if err != nil { break } c.init() go func(remoteConn net.Conn) { c.cbSend[remoteConn] = func(msg string) { remoteConn.Write([]byte(msg)) } for { buf := make([]byte, 32*512) rlen, err := remoteConn.Read(buf) if err != nil { delete(c.cbSend, remoteConn) break } if c.onRecv != nil { c.onRecv(strings.TrimSpace(string(buf[0:rlen]))) } } }(wsconn) } }
func (c *vncRemoton) startRPC(caps common.Capabilities, session *remoton.SessionClient, addrSrv string) { l := session.Listen("rpc") srv := rpc.NewServer() srv.Register(&common.RemotonClient{ Capabilities: &caps, NatIF: c.natif, }) srv.Accept(l) }