// Invoked when any sign in operation has completed private void DidLogin(Gamer newGamer) { if (Gamer != null) { Debug.LogWarning("Current gamer " + Gamer.GamerId + " has been dismissed"); Loop.Stop(); } Gamer = newGamer; Loop = Gamer.StartEventLoop(); Loop.ReceivedEvent += Loop_ReceivedEvent; Debug.Log("Signed in successfully (ID = " + Gamer.GamerId + ")"); //Save the User for reconnect later SaveGamer(Gamer); //Add register field for stop being a guest var loginUI = FindObjectOfType <LoginUI>(); loginUI.updateUI(); var profile = FindObjectOfType <ProfileScript>(); //Update profile if (profile != null) { profile.UpdateProfile(); } }
// Invoked when any sign in operation has completed private void DidLogin(Gamer newGamer) { if (Gamer != null) { Debug.LogWarning("Current gamer " + Gamer.GamerId + " has been dismissed"); Loop.Stop(); } Gamer = newGamer; Loop = Gamer.StartEventLoop(); Loop.ReceivedEvent += Loop_ReceivedEvent; Debug.Log("Signed in successfully (ID = " + Gamer.GamerId + ")"); }
/// <summary> /// Stop the events loop to retrieve server pending events. A stopped events loop shouldn't be started again. /// </summary> public static void Handling_StopEventsListening() { // Stop the events loop if (eventLoop != null) { eventLoop.Stop(); eventLoop = null; if (verboseEventLoop) { DebugLogs.LogVerbose("[CotcSdkTemplate:EventFeatures] Unregistered from gamer's events loop"); } } }
/// <summary> /// Start the events loop to retrieve server pending events as soon as possible. /// </summary> /// <param name="loggedInGamer">The logged in gamer's instance.</param> /// <param name="verbose">If the events loop registering / unregistering and the received events should be logged into the console.</param> public static void Handling_StartEventsListening(Gamer loggedInGamer, bool verbose = true) { // Start the events loop from the currently logged in gamer then register a received event callback eventLoop = loggedInGamer.StartEventLoop(); eventLoop.ReceivedEvent += OnEventReceived; // Set if the events handling should be verbose verboseEventLoop = verbose; if (verboseEventLoop) { DebugLogs.LogVerbose("[CotcSdkTemplate:EventFeatures] Registered to gamer's events loop"); } }
void Cotc_GotDomainLoopEvent(DomainEventLoop sender, EventLoopArgs args) { // When we receive a message, it means that the pending notification has been approved, so reset the application badge #if UNITY_IPHONE if (args.Message.Has("osn")) { Debug.LogWarning ("Will clear events"); UnityEngine.iOS.NotificationServices.ClearRemoteNotifications(); var setCountNotif = new UnityEngine.iOS.LocalNotification(); setCountNotif.fireDate = System.DateTime.Now; setCountNotif.applicationIconBadgeNumber = -1; setCountNotif.hasAction = false; UnityEngine.iOS.NotificationServices.ScheduleLocalNotification(setCountNotif); } #endif }
void Cotc_GotDomainLoopEvent(DomainEventLoop sender, EventLoopArgs args) { // When we receive a message, it means that the pending notification has been approved, so reset the application badge #if UNITY_IPHONE if (args.Message.Has("osn")) { Debug.LogWarning("Will clear events"); UnityEngine.iOS.NotificationServices.ClearRemoteNotifications(); var setCountNotif = new UnityEngine.iOS.LocalNotification(); setCountNotif.fireDate = System.DateTime.Now; setCountNotif.applicationIconBadgeNumber = -1; setCountNotif.hasAction = false; UnityEngine.iOS.NotificationServices.ScheduleLocalNotification(setCountNotif); } #endif }
private IEnumerator DidLogin(Gamer newGamer, float faketime = 3) { if (Gamer != null) { Debug.LogWarning("Current gamer " + Gamer.GamerId + " has been dismissed"); //Loop.Stop(); } Gamer = newGamer; Loop = Gamer.StartEventLoop(); Loop.ReceivedEvent += Loop_ReceivedEvent; SetLastGamer(Gamer); //Fake time so we can see the animation playing yield return(new WaitForSecondsRealtime(faketime)); loading = false; Debug.Log("Signed in successfully (ID = " + Gamer.GamerId + ")"); Play(1); }
/// <summary> /// Once an event is retrieved from the server, check its type and call the corresponding callback. /// </summary> /// <param name="sender">The event loop instance which raised the event.</param> /// <param name="eventData">Received event's data.</param> private static void OnEventReceived(DomainEventLoop sender, EventLoopArgs eventData) { // Get the Bundle data from the raised event Bundle eventBundle = eventData.Message; if (verboseEventLoop) { DebugLogs.LogVerbose(string.Format("[CotcSdkTemplate:EventFeatures] Received event ›› {0}", eventBundle.ToString())); } switch (eventBundle["type"].AsString()) { // Event type: message sent from the BackOffice case "backoffice": if (Event_BackOfficeMessage == null) { DebugLogs.LogError(string.Format(noEventCallbackFormat, "Event_BackOfficeMessage")); } else { Event_BackOfficeMessage(eventBundle); } break; // Event type: another gamer added the currently logged in one as friend (automatic) case "friend.add": DebugLogs.LogWarning(string.Format(soonDeprecatedEvent, "friend.add")); break; // Event type: another gamer added the currently logged in one as blacklisted (automatic) case "friend.blacklist": DebugLogs.LogWarning(string.Format(soonDeprecatedEvent, "friend.blacklist")); break; // Event type: another gamer removed the currently logged in one from friend/blacklisted (automatic) case "friend.forget": DebugLogs.LogWarning(string.Format(soonDeprecatedEvent, "friend.forget")); break; // Event type: another gamer used the currently logged in one's referral code (automatic) case "godchildren": if (Event_NewGodchild == null) { DebugLogs.LogError(string.Format(noEventCallbackFormat, "Event_NewGodchild")); } else { Event_NewGodchild(eventBundle); } break; // Event type: message sent from another gamer (our "custom" events sent by gamer.Community.SendEvent() are of this type) case "user": OnCustomEventReceived(eventBundle); break; // Unhandled event types default: DebugLogs.LogError(string.Format("[CotcSdkTemplate:EventFeatures] An unhandled event has been received ›› {0}", eventBundle.ToString())); break; } }
private void Loop_ReceivedEvent(DomainEventLoop sender, EventLoopArgs e) { Debug.Log("Received event of type " + e.Message.Type + ": " + e.Message.ToJson()); }