|
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
-
- namespace SUISS.Cloud
- {
- public class SSPInboxController
- {
- public SSPInboxController(IFriendsController friendsController, GiftController giftController)
- {
- this._friendsController = friendsController;
- this._giftController = giftController;
- }
-
- public CloudRequest<Inbox, InboxErrors?> RefreshLists()
- {
- return new CloudRequest<Inbox, InboxErrors?>(this.CoRefreshLists());
- }
-
- private IEnumerator CoRefreshLists()
- {
- CloudRequest<FriendErrors?> refreshTask = this._friendsController.RefreshLists();
- yield return refreshTask;
- if (refreshTask.Error != null)
- {
- UnityEngine.Debug.LogError("Error refreshing friends list: " + refreshTask.Error);
- }
- CloudRequest<IList<IGift>, GiftErrors?> giftInboxTask = this._giftController.Inbox();
- yield return giftInboxTask;
- if (giftInboxTask.Error != null)
- {
- UnityEngine.Debug.LogError("Error retrieving gifts inbox: " + giftInboxTask.Error);
- }
- if (refreshTask.Error != null || giftInboxTask.Error != null)
- {
- if (refreshTask.Error == FriendErrors.NoInternet || giftInboxTask.Error == GiftErrors.NoInternet)
- {
- yield return new YieldError<InboxErrors?>(new InboxErrors?(InboxErrors.NoInternet));
- }
- if (giftInboxTask.Error == GiftErrors.PlayernamesNotLoggedIn)
- {
- yield return new YieldError<InboxErrors?>(new InboxErrors?(InboxErrors.PlayernamesNotLoggedIn));
- }
- yield return new YieldError<InboxErrors?>(new InboxErrors?(InboxErrors.GeneralError));
- }
- yield return new YieldResult<Inbox>(new Inbox(giftInboxTask.Result));
- yield break;
- }
-
- private IFriendsController _friendsController;
-
- private GiftController _giftController;
- }
- }
|