Esempio n. 1
0
func NewService() *Service {
	inner := client.NewClient()
	service := Service{
		Conn: inner,
	}
	// Not ready to send until we have a name
	<-service.Ready
	// Set Recv to MethodMap which will call the correct method
	service.Recv = service.MethodMap
	return &service
}
Esempio n. 2
0
func NewClient() *client.Conn {
	ws := client.NewClient()
	ws.Recv = func(m []byte) {}
	ws.ClientId, _ = os.Hostname()
	wsUrl := fmt.Sprintf("http://%s:%d/ws", "carpoolme.net", 8081)
	err := ws.Connect(wsUrl)
	if err != nil {
		log.Println(err)
	}
	go ws.Read()
	startMessage := fmt.Sprintf("Started %s", ws.ClientId)
	ws.Write([]byte(startMessage))
	return ws
}