-
Notifications
You must be signed in to change notification settings - Fork 8
getStats メソッドを追加する #212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getStats メソッドを追加する #212
Conversation
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
| suspendCancellableCoroutine { continuation -> | ||
| // 現在の PeerChannel インスタンスを取得 | ||
| val currentPeer = peer | ||
| // PeerChannel がまだ存在しない場合のガード |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
切断済みの場合でも null のはずなので まだ はいらなそうです
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
たしかにそうですね、修正します
| val currentPeer = peer | ||
| // PeerChannel がまだ存在しない場合のガード | ||
| if (currentPeer == null) { | ||
| // 結果なしを即時返却 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
関数ドキュメントにも書いていますが、結果なし を返しているのではなく、null を明示的に返すようにしているので null を返す、にした方がよさそうです
|
|
||
| currentPeer.getStats { report -> | ||
| // コルーチンがまだアクティブな場合に結果を返却 | ||
| // そうでない場合は何もしない |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
何もしないで大丈夫なんでしたっけ
continuation.resume(null) で終わる必要ないですか?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
アクティブでないなら大丈夫なのか?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
大丈夫です。
すでにキャンセルされてしまってるので resume すると例外が発生するので、例外発生させるのではなくここはキャンセルされた場合スルーするようにしています。
本来はキャンセルされたときの処理を書けという感じなのですが、ラップしてる非同期コールバックの getStats 呼び出しをキャンセルする方法がなさそうなので、このようにしています。
No description provided.