Beispiel #1
0
        void getResponse(Socket client)
        {
            //convert the response to a readable manner for C#
            byte[] messageBytes = new byte[2048];
            //receive message from the server
            int messageInt = client.Receive(messageBytes);
            //convert the string from the byte array - should be shown in json format
            string messageString = System.Text.Encoding.ASCII.GetString(messageBytes, 0, messageInt);

            try {
                //fix the json format as it does not match GO langs format
                messageString = fixJson(messageString);
                //create a list of servers - using the names of the servers amd Ip addresses
                ServerList result = JsonUtility.FromJson <ServerList>(messageString);
                //set the list so that it can be shown to the user
                ServerGUI.Instance.setList(result.list);
            }
            catch (Exception) {
                //show debug message to show that the list was not retreived,
                //as an empty list may show the same screen
                Debug.Log("Could Not get List of Servers ");
            }
            //close the client socket
            client.Close();
        }
Beispiel #2
0
 // Use this for initialization
 void Start()
 {
     _serverlist = this;
 }