Skip to content

Instantly share code, notes, and snippets.

@TORISOUP
Last active August 29, 2015 14:15
Show Gist options
  • Save TORISOUP/7f0ae5b98fd4ea8769b3 to your computer and use it in GitHub Desktop.
Save TORISOUP/7f0ae5b98fd4ea8769b3 to your computer and use it in GitHub Desktop.
UniRx & HttpWebRequest
Observable.Start(() =>
{
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create("http://google.com");
return (HttpWebResponse)webRequest.GetResponse();
})
.CatchIgnore((WebException e) =>
{
//WebException発生時の処理
Debug.LogError(e.Status);
})
.Select(x => (int)x.StatusCode) //ステータスコードに変換
.ObserveOnMainThread()
.Subscribe(statusCode => Debug.Log(statusCode)); //ステータスコード表示
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment