Ejemplo n.º 1
0
func createClient() {
	defer func() {
		fmt.Printf("createClient func done !")
	}()
	addr := "localhost:8600"

	client_id := int64(451294706224070657)
	c := client.NewClient(addr, client_id)
	c.Register("localhost:4171")
	c.Connect()

	channel_id := int64(1001)
	c.Subscribe(channel_id)
}
Ejemplo n.º 2
0
func main() {
	fmt.Println("client start!")

	addr := "localhost:8600"
	client_id := int64(451294706224070657)
	c := client.NewClient(addr, client_id)
	c.Register("localhost:4171")
	c.Connect()

	channel_id := int64(1001)
	c.Subscribe(channel_id)

	exitChan := make(chan int)
	signalChan := make(chan os.Signal, 1)
	go func() {
		<-signalChan
		exitChan <- 1
	}()
	signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM)

	<-exitChan
	c.Close()

}