public static BasicAuthMiddleware Add(AsyncHttpClient client) { BasicAuthMiddleware ret = new BasicAuthMiddleware(); client.Middleware.Add(ret); return(ret); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); if (cacher == null) { try { cacher = ResponseCacheMiddleware.AddCache(AsyncHttpClient.DefaultInstance, GetFileStreamPath("asynccache"), 1024 * 1024 * 10); cacher.Caching = false; } catch { Toast.MakeText(ApplicationContext, "unable to create cache", ToastLength.Short).Show(); } } if (auther == null) { try { auther = BasicAuthMiddleware.Add(AsyncHttpClient.DefaultInstance); auther.SetAuthorization("http://www.google.com", "username", "password"); } catch { Toast.MakeText(ApplicationContext, "unable to create basic auth", ToastLength.Short).Show(); } } SetContentView(Resource.Layout.activity_main); Button b = FindViewById <Button> (Resource.Id.go); b.Click += delegate { Refresh(); }; Button s = FindViewById <Button> (Resource.Id.sockets); s.Click += async delegate { await ConnectSocketsAsync(); }; rommanager = FindViewById <ImageView> (Resource.Id.rommanager); tether = FindViewById <ImageView> (Resource.Id.tether); desksms = FindViewById <ImageView> (Resource.Id.desksms); chart = FindViewById <ImageView> (Resource.Id.chart); socketsEcho = FindViewById <TextView> (Resource.Id.socketsEcho); ShowCacheToast(); }