ClientScript.readSocket C# (CSharp) Method

readSocket() public method

public readSocket ( ) : String
return String
    public String readSocket()
    {
        if (!ready)
        {
            Debug.Log("Socket not ready to read.");
            return null;
        }
        try
        {
            String line = reader.ReadLine();
            return line;
        }
        catch (Exception e)
        {
            Debug.Log("Problem reading data: "+e);
            return null;
        }
    }

Usage Example

    private void StartGameLoop()
    {

        cs = GameObject.Find("ClientScript").GetComponentInChildren<ClientScript>();
        //WWW results = cs.GET("http://answers.unity3d.com/questions/208309/get-request-wrapper.html");
        // Debug.Log(results.text);
        //depending on the data we are polling, we will be making different get requests

        //  var N = JSON.Parse(results.text);

        //two get requests -> one to request for new names to sacrifice and one for a status check and confirmation to the server
        Debug.Log("Starting TCP socket connection");
        cs.socketInit();
        // cs.writeSocket("test!");

            String str = cs.readSocket();
            while (str == null)
            {
                Debug.Log("str is null");
                str = cs.readSocket();
            }
            Debug.Log(str);
        
        cs.closeSocket();
    }