예제 #1
0
 private void OnNotificationClicked(ReceivedNotification notification)
 {
     if (notification.id == "dailyReward".GetHashCode())
     {
         TankAnalytics.AppStartReason("dailyReward");
     }
     else if (notification.id == "freeUpgrade".GetHashCode())
     {
         TankAnalytics.AppStartReason("freeUpgrade");
     }
     else if (notification.id == "weMissYouTraditional".GetHashCode())
     {
         TankAnalytics.AppStartReason("weMissYouTraditional");
     }
     else if (notification.id == "weMissYouIncentive".GetHashCode())
     {
         TankAnalytics.AppStartReason("weMissYouIncentive");
     }
     else if (notification.id == "weMissYouCompetitive".GetHashCode())
     {
         TankAnalytics.AppStartReason("weMissCompetitive");
     }
     else if (notification.id == "coinBonus".GetHashCode())
     {
         TankAnalytics.AppStartReason("coinBonus");
         LoadingScreen.OpenShopOnLoad();
     }
     else if (notification.id == "chestUnopened".GetHashCode())
     {
         TankAnalytics.AppStartReason("chestUnopened");
         LoadingScreen.OpenShopOnLoad();
     }
     else if (notification.id == "chestReady".GetHashCode())
     {
         TankAnalytics.AppStartReason("chestReady");
         LoadingScreen.OpenShopOnLoad();
     }
     else if (notification.id == "xmasPresent".GetHashCode())
     {
         TankAnalytics.AppStartReason("xmasPresent");
     }
 }
예제 #2
0
        private void onReceiveNotifications(IList <ReceivedNotification> notifications)
        {
            IEnumerator <ReceivedNotification> enumerator = notifications.GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    string str;
                    int    num;
                    ReceivedNotification current = enumerator.Current;
                    current.userData.TryGetValue("nskclientaction", out str);
                    string key = str;
                    if (key == null)
                    {
                        return;
                    }
                    if (< > f__switch$map9 == null)
                    {
                        Dictionary <string, int> dictionary2 = new Dictionary <string, int>(2);
                        dictionary2.Add("updateplayer", 0);
                        dictionary2.Add("updatetournament", 1);
                        < > f__switch$map9 = dictionary2;
                    }
예제 #3
0
        private void ReceivedMessage(ArraySegment <byte> buffer)
        {
            var contents = System.Text.Encoding.UTF8.GetString(buffer.Array, buffer.Offset, buffer.Count);

            var envelope = contents.FromJson <WebSocketMessageEnvelope>();

            try
            {
                if (!string.IsNullOrEmpty(envelope.Cid))
                {
                    // Handle message response.
                    TaskCompletionSource <WebSocketMessageEnvelope> completer;
                    var cid = envelope.Cid;
                    _responses.TryRemove(cid, out completer);
                    if (completer == null)
                    {
                        Logger?.ErrorFormat("No completer for message cid: {0}", envelope.Cid);
                        return;
                    }

                    if (envelope.Error != null)
                    {
                        completer.SetException(new WebSocketException(WebSocketError.InvalidState,
                                                                      envelope.Error.Message));
                    }
                    else
                    {
                        completer.SetResult(envelope);
                    }
                }
                else if (envelope.Error != null)
                {
                    ReceivedError?.Invoke(new WebSocketException(WebSocketError.InvalidState, envelope.Error.Message));
                }
                else if (envelope.ChannelMessage != null)
                {
                    ReceivedChannelMessage?.Invoke(envelope.ChannelMessage);
                }
                else if (envelope.ChannelPresenceEvent != null)
                {
                    ReceivedChannelPresence?.Invoke(envelope.ChannelPresenceEvent);
                }
                else if (envelope.MatchmakerMatched != null)
                {
                    ReceivedMatchmakerMatched?.Invoke(envelope.MatchmakerMatched);
                }
                else if (envelope.MatchPresenceEvent != null)
                {
                    ReceivedMatchPresence?.Invoke(envelope.MatchPresenceEvent);
                }
                else if (envelope.MatchState != null)
                {
                    ReceivedMatchState?.Invoke(envelope.MatchState);
                }
                else if (envelope.NotificationList != null)
                {
                    foreach (var notification in envelope.NotificationList.Notifications)
                    {
                        ReceivedNotification?.Invoke(notification);
                    }
                }
                else if (envelope.StatusPresenceEvent != null)
                {
                    ReceivedStatusPresence?.Invoke(envelope.StatusPresenceEvent);
                }
                else if (envelope.StreamPresenceEvent != null)
                {
                    ReceivedStreamPresence?.Invoke(envelope.StreamPresenceEvent);
                }
                else if (envelope.StreamState != null)
                {
                    ReceivedStreamState?.Invoke(envelope.StreamState);
                }
                else
                {
                    Logger?.ErrorFormat("Received unrecognised message: '{0}'", contents);
                }
            }
            catch (Exception e)
            {
                ReceivedError?.Invoke(e);
            }
        }
예제 #4
0
        private void ReceivedMessage(ArraySegment <byte> buffer)
        {
            var contents = System.Text.Encoding.UTF8.GetString(buffer.Array, buffer.Offset, buffer.Count);

            Logger?.DebugFormat("Received JSON over web socket: {0}", contents);

            var envelope = contents.FromJson <WebSocketMessageEnvelope>();

            try
            {
                if (!string.IsNullOrEmpty(envelope.Cid))
                {
                    lock (_lockObj)
                    {
                        // Handle message response.
                        if (_responses.ContainsKey(envelope.Cid))
                        {
                            TaskCompletionSource <WebSocketMessageEnvelope> completer = _responses[envelope.Cid];
                            _responses.Remove(envelope.Cid);

                            if (envelope.Error != null)
                            {
                                completer.SetException(new WebSocketException(WebSocketError.InvalidState, envelope.Error.Message));
                            }
                            else
                            {
                                completer.SetResult(envelope);
                            }
                        }
                        else
                        {
                            Logger?.ErrorFormat("No completer for message cid: {0}", envelope.Cid);
                        }
                    }
                }
                else if (envelope.Error != null)
                {
                    ReceivedError?.Invoke(new WebSocketException(WebSocketError.InvalidState, envelope.Error.Message));
                }
                else if (envelope.ChannelMessage != null)
                {
                    ReceivedChannelMessage?.Invoke(envelope.ChannelMessage);
                }
                else if (envelope.ChannelPresenceEvent != null)
                {
                    ReceivedChannelPresence?.Invoke(envelope.ChannelPresenceEvent);
                }
                else if (envelope.MatchmakerMatched != null)
                {
                    ReceivedMatchmakerMatched?.Invoke(envelope.MatchmakerMatched);
                }
                else if (envelope.MatchPresenceEvent != null)
                {
                    ReceivedMatchPresence?.Invoke(envelope.MatchPresenceEvent);
                }
                else if (envelope.MatchState != null)
                {
                    ReceivedMatchState?.Invoke(envelope.MatchState);
                }
                else if (envelope.NotificationList != null)
                {
                    foreach (var notification in envelope.NotificationList.Notifications)
                    {
                        ReceivedNotification?.Invoke(notification);
                    }
                }
                else if (envelope.StatusPresenceEvent != null)
                {
                    ReceivedStatusPresence?.Invoke(envelope.StatusPresenceEvent);
                }
                else if (envelope.StreamPresenceEvent != null)
                {
                    ReceivedStreamPresence?.Invoke(envelope.StreamPresenceEvent);
                }
                else if (envelope.StreamState != null)
                {
                    ReceivedStreamState?.Invoke(envelope.StreamState);
                }
                else if (envelope.Party != null)
                {
                    ReceivedParty?.Invoke(envelope.Party);
                }
                else if (envelope.PartyClose != null)
                {
                    ReceivedPartyClose?.Invoke(envelope.PartyClose);
                }
                else if (envelope.PartyData != null)
                {
                    ReceivedPartyData?.Invoke(envelope.PartyData);
                }
                else if (envelope.PartyJoinRequest != null)
                {
                    ReceivedPartyJoinRequest?.Invoke(envelope.PartyJoinRequest);
                }
                else if (envelope.PartyLeader != null)
                {
                    ReceivedPartyLeader?.Invoke(envelope.PartyLeader);
                }
                else if (envelope.PartyMatchmakerTicket != null)
                {
                    ReceivedPartyMatchmakerTicket?.Invoke(envelope.PartyMatchmakerTicket);
                }
                else if (envelope.PartyPresenceEvent != null)
                {
                    ReceivedPartyPresence?.Invoke(envelope.PartyPresenceEvent);
                }
                else
                {
                    Logger?.ErrorFormat("Received unrecognised message: '{0}'", contents);
                }
            }
            catch (Exception e)
            {
                ReceivedError?.Invoke(e);
            }
        }