Beispiel #1
0
        public void HelloMessageHandler(HelloMessage message)
        {
            var packedMessage = new IdentifyMessage()
            {
                Token            = "Bot " + DiscordClient.Instance.Token,
                ClientProperties = new IdentifyConnection()
                {
                    browser = "AlpaBot",
                    device  = "AlpaBot",
                    os      = "windows"
                },
                LargeThreshold = 250,
                Compress       = true,
                ShardInfo      = new ShardInfo()
                {
                    ShardCount = 1,
                    ShardId    = 0
                },
            };

            var msg = new BaseMessage()
            {
                Data   = packedMessage,
                OpCode = GatewayOpCode.Identify
            };

            DiscordClient.Send(msg);

            DiscordClient.Instance.Heartbeat = message.heartbeat_interval;
            DiscordClient.Instance.SetTimer();
        }
        private void SetEmailDetails(IdentifyMessage identifyMessage)
        {
            switch (identifyMessage.Reason)
            {
                case Messages.Enums.IdentifyMessageReason.CanceledIdentification:

                    break;
                case Messages.Enums.IdentifyMessageReason.Identified:
                    user = identifyMessage.User;

                    if (isInAppLogin)
                        UnitOfWork.UserRepository.Update(user);
                    else
                        UnitOfWork.UserRepository.Insert(user);
                    UnitOfWork.Save();

                    base.HideHeaderLoader();
                    EmailTextBoxIsEnabled = true;

                    if (isInAppLogin)
                        NavigationService.NavigateTo("/Views/Profile.xaml");
                    else
                        NavigationService.NavigateTo("/Views/SplashScreen.xaml?pagestate=Bumblelogin");

                    break;
            }

        }
Beispiel #3
0
 public GatewayClient(string identity)
 {
     json              = new JavaScriptSerializer();
     this.identity     = json.Deserialize <IdentifyMessage>(identity);
     OnConnected      += () => { };
     OnReceiveMessage += (_) => { };
 }
        private void Authorise()
        {
            Pin pin;

            try
            {
                pin = Pin.CreateFrom(OneTimePin);
            }
            catch (Exception e)
            {
                base.ShowPopup(CustomPopupMessageType.Error, e.Message, AppResources.CustomPopupGenericOkMessage, null);
                return;
            }

            base.ShowHeaderLoader();
            OneTimePinTextBoxIsEnabled = false;

            Action identify = async() =>
            {
                try
                {
                    cancellationTokenSource = new CancellationTokenSource();

                    user = await DrumbleApi.Identify(cancellationTokenSource.Token, email, pin);

                    if (user != null)
                    {
                        base.HideHeaderLoader();
                        OneTimePinTextBoxIsEnabled = true;

                        IdentifyMessage.Send(user, Messages.Enums.IdentifyMessageReason.Identified);

                        NavigationService.GoBack();
                    }
                    else
                    {
                        // TODO error display something went wrong... but what?
                    }
                }
                catch (Exception e)
                {
                    base.HideHeaderLoader();
                    OneTimePinTextBoxIsEnabled = true;

                    base.ShowPopup(CustomPopupMessageType.Error, e.Message, AppResources.CustomPopupGenericOkMessage, null);
                }
            };

            DispatcherHelper.CheckBeginInvokeOnUI(identify);
        }
        private void Cancel()
        {
            if (cancellationTokenSource != null)
            {
                cancellationTokenSource.Cancel();

                OneTimePin = AppResources.IdentifyOneTimePinWaterMarkText;
                OneTimePinTextBoxIsEnabled = true;
                base.HideHeaderLoader();
            }

            IdentifyMessage.Send(null, Messages.Enums.IdentifyMessageReason.CanceledIdentification);

            NavigationService.GoBack();
        }
Beispiel #6
0
        private void SetEmailDetails(IdentifyMessage identifyMessage)
        {
            switch (identifyMessage.Reason)
            {
            case Messages.Enums.IdentifyMessageReason.CanceledIdentification:

                break;

            case Messages.Enums.IdentifyMessageReason.Identified:
                user = identifyMessage.User;

                if (isInAppLogin)
                {
                    UnitOfWork.UserRepository.Update(user);
                }
                else
                {
                    UnitOfWork.UserRepository.Insert(user);
                }
                UnitOfWork.Save();

                base.HideHeaderLoader();
                EmailTextBoxIsEnabled = true;

                if (isInAppLogin)
                {
                    NavigationService.NavigateTo("/Views/Profile.xaml");
                }
                else
                {
                    NavigationService.NavigateTo("/Views/SplashScreen.xaml?pagestate=Bumblelogin");
                }

                break;
            }
        }