private bool onUserEnter(DataMessage message) { message.createReader(); Dictionary<string, object> json = message.readJson(); message.closeReader(); ChatUser u = new ChatUser(); if (u.fromJson(json)) { if (u.userId == systemController.getUserInfo().userId) { postUpdate(UiUpdates.GameIsReady, null); } else { if (!users.ContainsKey(u.userId)) { users.Add(u.userId, u); } postUpdate(UiUpdates.NewUser, u); } } return false; }
private bool onReceivePlayersList(DataMessage message) { message.createReader(); int callback = message.readInt32(); if (callback != myCallback) { Debug.LogError("receive users list, but invalid Callback"); } Dictionary<string, object> json = message.readJson(); message.closeReader(); object[] usersJson = (object[])json["users"]; for (int i = 0; i < usersJson.Length; i++) { ChatUser u = new ChatUser(); if (u.fromJson((Dictionary<string, object>)usersJson[i])) { users[u.userId] = u; } } postUpdate(UiUpdates.UpdateUsersList, null); sendUserReady(); return false; }