public void OnRoomParticipated(RoomParticipatedDTO roomParticipatedDTO) { if (_httpToken.UserId == roomParticipatedDTO.UserId.ToString()) { var room = OtherRooms.Where(r => r.Id == roomParticipatedDTO.RoomId).FirstOrDefault(); ChangeData(delegate { MyRooms.Add(room); OtherRooms.Remove(room); }); } }
// Use this for initialization IEnumerator Start() { officeList = new MyRooms(); personList = new Personnel(); list = new List <GameObject>(); string url = "http://localhost:5000/room/"; WWWForm form = new WWWForm(); form.AddField("username", "asd"); form.AddField("password", "asd"); var headers = form.headers; byte[] rawData = form.data; headers["Authorization"] = "kLVHntU5YCsQku6GPf1Ehz9cPJ4lwO7krUOgICtSOefIiJ2QGZkbrlXiAXPH"; using (WWW www = new WWW(url, rawData, headers)) { yield return(www); if (www.error == null) { officeList = JsonUtility.FromJson <MyRooms>(www.text); foreach (MyRoomData room in officeList.rooms) { GameObject newOffice = (GameObject)GameObject.Instantiate(officePrefab); newOffice.transform.SetParent(contentPanel, false); RoomPrefab prefab = newOffice.GetComponent <RoomPrefab>(); prefab.Setup(room); list.Add(newOffice); } } else { Debug.Log("ERROR: " + www.error); } } url = "http://localhost:5000/personnel/"; using (WWW www = new WWW(url, rawData, headers)) { yield return(www); if (www.error == null) { personList = JsonUtility.FromJson <Personnel>(www.text); navScript.GetPersonnelList(this.personList); } else { Debug.Log("ERROR: " + www.error); } } }
public async void OnRoomCreated(RoomDTO room) { var userProfile = await GetUserAsync(room.AdminId); if (userProfile == null) { return; } if (room.AdminId.ToString() == _httpToken.UserId) { ChangeData(delegate { MyRooms.Insert(0, new RoomModel(room, userProfile)); }); } else { ChangeData(delegate { OtherRooms.Insert(0, new RoomModel(room, userProfile)); }); } }