protected void init(CarLogin c, RaceController raceController)
    {
        if (c.name == null || c.name == "")
        {
            throw new JoinException("CarInfo.name missing");
        }
        if (c.teamId == null || c.teamId == "")
        {
            throw new JoinException("CarInfo.teamId missing");
        }

        var raceParameters = RaceParameters.readRaceParameters();
        var cars           = raceParameters.cars;
        var found          = cars?.FirstOrDefault(d => d.teamId == c.teamId);

        if (found != null)
        {
            carInfo = found;
        }
        else if (raceParameters.mode == "race")
        {
            throw new JoinException("Team not found by teamId: " + c.teamId);
        }
        else
        {
            carInfo = new CarInfo(c.teamId, c.name, c.color);
        }

        this.imageWidth  = (c.imageWidth < 8 || c.imageWidth > 128) ? 128 : (uint)c.imageWidth;
        this.imageHeight = imageWidth * IMAGE_HEIGHT / IMAGE_WIDTH;
        Debug.Log("Using car name " + carInfo.name + " and image size " + imageWidth + "x" + imageHeight);

        raceController.CarConnected(new CarConnected(carInfo, this));

        FrameRequested = true;
    }
 public WebCarSocket(CarLogin login, WebRaceController controller)
 {
     init(login, controller.raceController);
     this.controller = controller;
 }