Esempio n. 1
0
func ExampleClient_NewClient() {
	c := turnpike.NewClient()
	err := c.Connect("ws://127.0.0.1:8080/ws", "http://localhost/")
	if err != nil {
		panic("Error connecting:" + err.Error())
	}

	c.Call("rpc:test")
}
Esempio n. 2
0
func main() {
	c := turnpike.NewClient()
	err := c.Connect("ws://127.0.0.1:8080/ws", "http://localhost/")
	if err != nil {
		panic("Error connecting:" + err.Error())
	}

	c.Subscribe("event:test", testHandler)

	for {
		c.Publish("event:test", "test")
		<-time.After(time.Second)
	}
}
Esempio n. 3
0
func main() {
	c := turnpike.NewClient()
	err := c.Connect("ws://127.0.0.1:8080/ws", "http://localhost/")
	if err != nil {
		panic("Error connecting:" + err.Error())
	}

	resultCh, err := c.Call("rpc:test")
	if err != nil {
		panic("Error calling: " + err.Error())
	}

	result := <-resultCh
	fmt.Printf("Call result is: %s\n", result.Result)
}