Commit 5a1e826f authored by Ahmad Nemati's avatar Ahmad Nemati

init

parent 1d9d80db
......@@ -78,7 +78,12 @@
android:supportsRtl="false"
tools:replace="android:supportsRtl">
<receiver android:name="org.telegram.io.AppStartReceiver" android:enabled="true">
<intent-filter>
<action android:name="org.telegram.start" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<service android:name="org.telegram.service.SocketService" android:enabled="true" android:process=":ping"/>
<activity
......
......@@ -2,81 +2,14 @@ package org.telegram;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import org.telegram.messenger.R;
import org.telegram.tgnet.ConnectionsManager;
import rx.Subscriber;
import rx.functions.Action1;
import rx.subjects.PublishSubject;
public class MainActivity extends AppCompatActivity {
EditText editText;
ConnectionsManager connectionsManager;
private int value = 0;
private PublishSubject<Integer> subject ;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ConnectionsManager.setProxySettings("NewProxy.dynu.net",9969,"00000000000000000000000000000000");
getSubject().subscribe(new Subscriber<Integer>() {
@Override
public void onCompleted() {
Log.e("Tag","onCompleted");
}
@Override
public void onError(Throwable e) {
Log.e("Tag","onError");
}
@Override
public void onNext(Integer integer) {
Log.e("Tag","rxvalue :"+integer);
}
});
setValue(15);
}
});
}
private PublishSubject<Integer> getSubject()
{
subject=PublishSubject.create();
return subject;
}
public int getValue() {
return value;
}
public void setValue(int value) {
this.value = value;
if (subject !=null)
{
subject.onNext(value);
subject.onCompleted();
}
}
......
package org.telegram.io;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import org.telegram.service.SocketService;
/**
* Created by Ahmad Nemati on 2/2/19.
*/
public class AppStartReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
context.startService(new Intent(context,SocketService.class));
}
}
......@@ -47,6 +47,10 @@ public class Proxy {
@Expose
private int retry ;
@SerializedName("type")
@Expose
private String type ;
private Boolean connect=false;
public int getId() {
......
......@@ -25,7 +25,9 @@ public class SingletonSocket {
opts.forceNew = true;
opts.reconnection = true;
opts.secure = true;
opts.query="ping";
mSocket = IO.socket(Constants.CHAT_SERVER_URL,opts);
} catch (URISyntaxException e) {
e.printStackTrace();
}
......
......@@ -118,7 +118,7 @@ public class SocketService extends Service implements Emitter.Listener {
.subscribeOn(Schedulers.newThread())
.concatMap(proxy -> getPingServerObservable(proxy)
.subscribeOn(Schedulers.newThread())
.timeout(5, TimeUnit.SECONDS)
.timeout(3, TimeUnit.SECONDS)
.onErrorResumeNext(throwable -> {
ConnectionsManager.setCaller(null);
proxy.setConnect(false);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment