public void ProcessGetNames (NetworkResponse response) { ResponseConvergeGetNames args = response as ResponseConvergeGetNames; Debug.Log ("ResponseConvergeGetNames received"); playerNames.Clear(); playerNames.Add (args.player1ID, args.player1Name); playerNames.Add (args.player2ID, args.player2Name); playerNames.Add (args.player3ID, args.player3Name); playerNames.Add (args.player4ID, args.player4Name); Debug.Log ("Other player id / name"); // foreach (KeyValuePair<int, string> entry in playerNames) // { int id; foreach (DictionaryEntry entry in playerNames) { // do something with entry.Value or entry.Key id = (int) entry.Key; Debug.Log (" " + id + " " + entry.Value); if ((id <= 0 ) || (id == player_id)) { // playerNames.Remove (entry.Key); } else { // Debug.Log (" " + id + " " + entry.Value); } } }
// DH change // These are the player IDs and names for upto 4 opponents. // This is used to display information about the opponents // The player is not returned by the server // If less than 4 opponents exist then 0 and "" are returned public static NetworkResponse Parse(MemoryStream dataStream) { ResponseConvergeGetNames response = new ResponseConvergeGetNames(); using (BinaryReader br = new BinaryReader(dataStream, Encoding.UTF8)) { int player1ID = br.ReadInt32(); short fldSize = br.ReadInt16(); string player1Name = System.Text.Encoding.UTF8.GetString(br.ReadBytes(fldSize)); int player2ID = br.ReadInt32(); fldSize = br.ReadInt16(); string player2Name = System.Text.Encoding.UTF8.GetString(br.ReadBytes(fldSize)); int player3ID = br.ReadInt32(); fldSize = br.ReadInt16(); string player3Name = System.Text.Encoding.UTF8.GetString(br.ReadBytes(fldSize)); int player4ID = br.ReadInt32(); fldSize = br.ReadInt16(); string player4Name = System.Text.Encoding.UTF8.GetString(br.ReadBytes(fldSize)); response.player1ID = player1ID; response.player1Name = player1Name; response.player2ID = player2ID; response.player2Name = player2Name; response.player3ID = player3ID; response.player3Name = player3Name; response.player4ID = player4ID; response.player4Name = player4Name; } return(response); }