Beispiel #1
0
        private async void webSocket_Opened(object sender, EventArgs e)
        {
            await PhoneUtil.OnUiThread(() => Output = "Opened!");

            //var msg = @"{""cmd"":""status""}";
            //webSocket.Send(msg);
        }
Beispiel #2
0
        public override Task SuggestPremium()
        {
            var premiumDialog = new CustomMessageBox()
            {
                Caption            = IapStrings.SuggestPremiumTitle,
                Message            = IapStrings.SuggestPremiumContent,
                LeftButtonContent  = IapStrings.SuggestPremiumOkText,
                RightButtonContent = IapStrings.SuggestPremiumCancelText
            };

            premiumDialog.Dismissed += (s1, e1) => {
                switch (e1.Result)
                {
                case CustomMessageBoxResult.LeftButton:
                    PageNavigationService.Instance.Navigate(PageNames.IAP);
                    break;

                case CustomMessageBoxResult.RightButton:
                    break;

                case CustomMessageBoxResult.None:
                    break;
                }
            };
            return(PhoneUtil.OnUiThread(premiumDialog.Show));
        }
Beispiel #3
0
 public QRModel(VideoBrush video)
 {
     reader = new PhoneBarcodeReader();
     reader.CodeAvailable += async code => {
         await PhoneUtil.OnUiThread(() => Code = code);
     };
     this.video = video;
 }
 private async Task UpdateTransfersList()
 {
     // The Requests property returns new references, so make sure that
     // you dispose of the old references to avoid memory leaks.
     DisposeAll(TransferRequests);
     await PhoneUtil.OnUiThread(() => {
         TransferRequests = BackgroundTransferService.Requests;
     });
 }
Beispiel #5
0
        public SimpleWebSocket(Uri uri, AuthenticationHeaderValue authHeader, string mediaType)
            : base(uri, authHeader, mediaType)
        {
            // ServerCredentials property does not work
            var authHeaderPair = new KeyValuePair <string, string>(HttpUtil.Authorization, authHeader.Scheme + " " + authHeader.Parameter);
            var acceptHeader   = new KeyValuePair <string, string>(HttpUtil.Accept, MediaType);
            var headers        = new List <KeyValuePair <string, string> >()
            {
                authHeaderPair, acceptHeader
            };

            ws                  = new WebSocket(ServerUri.OriginalString, customHeaderItems: headers);
            ws.Closed          += (s, e) => OnClosed(String.Empty);
            ws.Error           += (s, e) => OnError();
            ws.MessageReceived += async(s, args) => {
                // Why UI thread?
                await PhoneUtil.OnUiThread(() => OnMessageReceived(args.Message));
            };
        }
Beispiel #6
0
 private async void webSocket_MessageReceived(object sender, MessageReceivedEventArgs e)
 {
     await PhoneUtil.OnUiThread(() => Output = e.Message);
 }
Beispiel #7
0
 private async Task SetOutput(string msg)
 {
     await PhoneUtil.OnUiThread(() => Output = msg);
 }
 private Task OnUiThread(Action code)
 {
     return(PhoneUtil.OnUiThread(code));
 }