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 }
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 }