public IEnumerator GetFriendListRecordCoroutine(uLobby.AccountID accountID, uLobby.Request <uLobby.FriendListRecord> request) { FriendListRecord friendList = StorageLayerUtility.FriendListRecordUtility.CreateFriendListRecord(); //read friend list var operation = ExecuteDataReaderAsync.BeginInvoke(storageManager.connectionString, "SELECT accounts.id,accounts.name,password,LENGTH(password),salt,LENGTH(salt),data,LENGTH(data) FROM accounts INNER JOIN friends ON accounts.id = friends.friend WHERE owner = @id", new MySqlParameter[] { new MySqlParameter("id", int.Parse(accountID.value)) }, null, null); while (!operation.IsCompleted) { yield return(null); } var dr = ExecuteDataReaderAsync.EndInvoke(operation); while (dr.Read()) { AccountRecord accountRecord = ReadAccountRecordFromDataReader(dr); Account account = StorageLayerUtility.CreateAccount(accountRecord); StorageLayerUtility.FriendListRecordUtility.AddFriend(friendList, StorageLayerUtility.CreateFriendInfo(account)); } dr.Close(); //read the original account owning the list. operation = ExecuteDataReaderAsync.BeginInvoke(storageManager.connectionString, "SELECT id,name,password,LENGTH(password),salt,LENGTH(salt),data,LENGTH(data) FROM accounts WHERE id = @id", new MySqlParameter[] { new MySqlParameter("id", int.Parse(accountID.value)) }, null, null); while (!operation.IsCompleted) { yield return(null); } dr = ExecuteDataReaderAsync.EndInvoke(operation); dr.Read(); Account originalAccount = StorageLayerUtility.CreateAccount(ReadAccountRecordFromDataReader(dr)); dr.Close(); //read invitations operation = ExecuteDataReaderAsync.BeginInvoke(storageManager.connectionString, "SELECT accounts.id,name,password,LENGTH(password),salt,LENGTH(salt),data,LENGTH(data) FROM accounts INNER JOIN invitations ON accounts.id = invitations.sender WHERE invitations.receiver = @id", new MySqlParameter[] { new MySqlParameter("id", int.Parse(accountID.value)) }, null, null); while (!operation.IsCompleted) { yield return(null); } dr = ExecuteDataReaderAsync.EndInvoke(operation); while (dr.Read()) { Account account = StorageLayerUtility.CreateAccount(ReadAccountRecordFromDataReader(dr)); StorageLayerUtility.FriendListRecordUtility.AddFriendInvitation(friendList, StorageLayerUtility.CreateFriendInvitation(account, originalAccount)); } dr.Close(); StorageLayerUtility.RequestUtility.SetResult(request, friendList); yield break; }
// SetFriendListRecordCoroutine IEnumerator IFriendOperations.SetFriendListRecordCoroutine(AccountID accountID, FriendListRecord record, Request request) { friendsLists[accountID] = record; yield break; }