Beispiel #1
0
func newLink(b *lazlo.Broker, path string, clickChan chan string) string {
	link_cb := b.LinkCallback(path)
	go func(link_cb *lazlo.LinkCallback, clickChan chan string) {
		for {
			<-link_cb.Chan
			clickChan <- link_cb.Path
		}
	}(link_cb, clickChan)
	return fmt.Sprintf("Ok, <%s|here> is a link on %s", link_cb.URL, path)
}
Beispiel #2
0
func newChoice(b *lazlo.Broker, clickChan chan string) string {
	opt1 := b.LinkCallback(`option1`)
	opt2 := b.LinkCallback(`option2`)
	go func(opt1 *lazlo.LinkCallback, opt2 *lazlo.LinkCallback, clickChan chan string) {
		for {
			select {
			case <-opt1.Chan:
				clickChan <- `THIS`
			case <-opt2.Chan:
				clickChan <- `THAT`
			}
		}
	}(opt1, opt2, clickChan)
	return fmt.Sprintf("you can get with <%s|THIS> or you can get with <%s|THAT>", opt1.URL, opt2.URL)
}