-
Notifications
You must be signed in to change notification settings - Fork 159
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
use okhttp-sse and drop jersey dependency #147
Conversation
This is still WIP, tests are missing (there was no test coverage for the old methods either). So, please help test and review. I'll do that as well. Meanwhile, please review the changes. Another issue is that some of the implementations I adapted looked like they were copy pasted and possibly wrong. E.g. PaymentsRequestBuilder was streaming OperationsResponse instead of PaymentOperationsResponse. I've not changed that and left it as it was. @bartekn it may be a good idea to use docker-compose to launch a standalone chain and run some integration tests against that. I've done this for my kotlin wrapper. See here for an example: This would require enabling docker support on travis. It's been a while since I did that but should be possible as well. Alternatively, we can write a simple test and point it at horizon testnet. Should be OK as long as it doesn't run too often. |
currently fails
Sadly does not yet work. Horizon is returning a mimetype of (application/hal+json; charset=utf-8) that okhttp-sse does not like. It seems to check for text/eventstream This API is marked as experimental on the okhttp side. I'll see if I can workaround this in some way. |
It returns the
However, Horizon requires |
@bartekn I have a working version now. Turns out you have to manually set the header on the request with okhttp-sse. A few changes:
From my point of view this seems kind of a convoluted pattern; but it works. The alternative of simply paging normal API requests and keeping track of the cursor would be about as complicated. This is actually what I implemented in out kotlin wrapper. Very straightforward to do with kotlin sequences. Another issue is that running background threads pretty much is a bad idea on Android. Let me know if you like this approach or if you would like changes to this. |
- Merge SSEUtils and SSEManager classes into a SSEStream class - track pagingToken via an atomic reference - tighten API by making most methods private/package protected - misc refactoring/renames
@bartekn Thanks for your review. I updated the PR and refactored a bit. There is now just one SSEStream class and most methods on it are private. |
remove public from constructor
handle goodbye event use lock to prevent edge case of restarting after calling close
@bartekn addressed your comments, have another look please. |
@bartekn It was 21 days. Can you review please? You get what you want after one day, but then nothing happens. 8 days ago I post about streaming issue, which is not working in your official sdk on StackExchange: https://stellar.stackexchange.com/questions/1945/subscribing-to-incoming-transaction-does-not-work ...now I tried this and this solves the streaming issue, it should be in main already. The person sent this pull request is highly skilled, he deserves more support. |
Many thanks for this @jillesvangurp and sorry for a delay once again! |
Fixes #141