예제 #1
0
파일: websocket.go 프로젝트: hraban/lush
func connectCmdsById(s *server, fromId, toId liblush.CmdId, streamname string) error {
	var stream liblush.OutStream
	var to, from liblush.Cmd
	from = s.session.GetCommand(fromId)
	if from == nil {
		return errors.New("unknown command in from")
	}
	switch streamname {
	case "stdout":
		stream = from.Stdout()
	case "stderr":
		stream = from.Stderr()
	default:
		return errors.New("unknown stream")
	}
	if toId == 0 {
		return disconnectStream(stream)
	}
	to = s.session.GetCommand(toId)
	if to == nil {
		return errors.New("unknown command in to")
	}
	if pipedcmd(stream) != nil {
		// not strictly necessary but makes for simpler API. service to the
		// user! because that is how we roll. EaaS.
		return errors.New("already connected to another command")
	}
	stream.SetListener(to.Stdin())
	return nil
}
예제 #2
0
파일: webhandlers.go 프로젝트: hraban/lush
func cmdloc(c liblush.Cmd) *url.URL {
	return &url.URL{Path: fmt.Sprintf("/%d/", c.Id())}
}