package client

import (
	"log"
	"net/url"
	"strconv"

	"github.com/gorilla/websocket"
)

func (client *Client) connectToServer() (err error) {
	u := url.URL{Scheme: "ws", Host: client.ServerAddress + ":" + strconv.Itoa(client.ServerPort), Path: "/ws"}
	log.Printf("Connecting to %s", u.String())

	// sigh
	client.conn, _, err = websocket.DefaultDialer.Dial(u.String(), nil)
	if err != nil {
		log.Fatal("ERROR: dialing - :", err)
		return err
	}
	return nil
}
