Last active
August 29, 2015 14:15
-
-
Save TORISOUP/7f0ae5b98fd4ea8769b3 to your computer and use it in GitHub Desktop.
UniRx & HttpWebRequest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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