Esempio n. 1
0
    public void Execute()
    {
        //  LoginBtn.onClick.Invoke();


        Debug.Log("Build test connection");
        //var stream = client.GetStream();
        //Debug.Log("Create Streams");
        //BinaryReader reader = new BinaryReader(stream);
        //BinaryWriter writer = new BinaryWriter(stream);
        // clientConn = new ClientConnection();
        var t = GetComponentInChildren <MenuManager>(true);



        connectionDispatcher.Start();
        Debug.Log("Write Login packages");
        string username = usernameInput.text;
        string pass     = passwordInput.text;

        connectionDispatcher.SendPackage(new LoginRequestPackage
        {
            Username = username,
            Password = pass,
        });

        Debug.Log("Receive Login response packages");
        //var packageData = packageParser.ParsePackageFromStream(clientConn.Reader);
        var packageData = this.connectionDispatcher.WaitForPackage <LoginResponsePackage>().Result;

        if (packageData.ErrorMsg == ErrorMsgTypes.Failed)
        {
            ErrorMsgText.color = Color.red;
            ErrorMsgText.text  = "There went Something Wrong with your Creditals";
        }
        else
        {
            ErrorMsgText.color = Color.green;
            ErrorMsgText.text  = "Login Successfull";
            Debug.Log($"Receive Login response packages TYPE: {packageData.GetType()} RESULT: {(packageData as LoginResponsePackage)?.IsValid}");

            menuManager.RaceSelectionMenu();
        }
    }
Esempio n. 2
0
    public void Execute()
    {
        Debug.Log("Build Connection");
        MenuManager menuManager = GetComponentInChildren <MenuManager>(true);

        clientConnection.Connect("127.0.0.1", 3456);
        connectionDispatcher.Start();
        string username = usernameInput.text;
        string password = passwordInput.text;

        connectionDispatcher.SendPackage(new LoginRequest()
        {
            Username = username, Password = password
        });

        Debug.Log("Waiting to receive Login Response Package");
        LoginResponse packageData = connectionDispatcher.WaitForPackage <LoginResponse>().Result; // TODO: automate this

        LogPackageResponse(packageData, packageData.IsValidLogin);
    }