SaeedDev94 / Xray

Xray GUI Client For Android
MIT License
201 stars 23 forks source link

Methods docs and synchronization #40

Open evgenybozhko2 opened 4 hours ago

evgenybozhko2 commented 4 hours ago

Hi man, thank you for this useful library. I can't understand why there needed a json() and test() methods, what they return? Also I see that the x-ray core to be ready for using should wait some times. the start() method is not synchronized, and we can't understand exactly time when the x-ray ready to use. Or maybe some callback onConnected(). Does it possible to make that?

SaeedDev94 commented 3 hours ago

test method validates the json config, it's same as xray run -test -c config.json in cli version, I want to make sure the user config is valid
json method parses link config (ex vless://xxx) to a simple json config for start method actually it doesn't matter when it will be ready as it's working correctly
BTW it's not a library =)

evgenybozhko2 commented 3 hours ago

for start method actually it doesn't matter when it will be ready as it's working correctly

If I do a request exactly after call the start method. I have got an exception and something like that. [javax.net.ssl.SSLHandshakeException: Connection closed by peer at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)]

But if I do a delay(2000) it works as expected. Do you know what Is the issue?

So I need to know how much time I should wait before executing the first request. For slow phones, it's 2 sec, for faster about 1sec. But the perfect way, will be has the possibility to know when exactly the x-ray is ready to use.

Best regards, Thanks