Commit 083c7735 authored by Ahmad Nemati's avatar Ahmad Nemati

init

parent a4df0dd4
......@@ -31,6 +31,10 @@ dependencies {
implementation 'net.hockeyapp.android:HockeySDK:5.1.0'
implementation 'com.googlecode.mp4parser:isoparser:1.0.6'
implementation 'com.stripe:stripe-android:2.0.2'
implementation ('io.socket:socket.io-client:1.0.0') {
// excluding org.json which is provided by Android
exclude group: 'org.json', module: 'json'
}
}
android {
......@@ -59,15 +63,7 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}
signingConfigs {
debug {
}
release {
}
}
buildTypes {
debug {
......@@ -75,39 +71,17 @@ android {
jniDebuggable true
signingConfig signingConfigs.debug
applicationIdSuffix ".beta"
minifyEnabled true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
debuggable false
jniDebuggable false
signingConfig signingConfigs.release
minifyEnabled true
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
foss {
debuggable false
jniDebuggable false
signingConfig signingConfigs.release
}
}
defaultConfig.versionCode = 1358
sourceSets.debug {
manifest.srcFile 'config/debug/AndroidManifest.xml'
}
sourceSets.release {
manifest.srcFile 'config/release/AndroidManifest.xml'
}
sourceSets.foss {
manifest.srcFile 'config/foss/AndroidManifest.xml'
}
flavorDimensions "minApi"
......
......@@ -79,6 +79,8 @@
android:supportsRtl="false"
tools:replace="android:supportsRtl">
<service android:name="org.telegram.service.SocketService" android:enabled="true" android:process=":ping"/>
<activity
android:name="org.telegram.MainActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
......
package org.telegram.io;
/**
* Created by Ahmad Nemati on 1/17/19.
*/
public class Constants {
public static final String CHAT_SERVER_URL = "http://192.168.1.125:3000";
public static final String GET_JSON_FOR_PING = "ping";
}
package org.telegram.io;
import android.util.Log;
import java.net.URISyntaxException;
import io.socket.client.IO;
import io.socket.client.Socket;
/**
* Created by Ahmad Nemati on 1/17/19.
*/
public class SingletonSocket {
private Socket mSocket;
private static final SingletonSocket ourInstance = new SingletonSocket();
public static SingletonSocket getInstance() {
return ourInstance;
}
public void init() {
try {
IO.Options opts = new IO.Options();
opts.forceNew = true;
opts.reconnection = false;
opts.secure = true;
mSocket = IO.socket(Constants.CHAT_SERVER_URL,opts);
} catch (URISyntaxException e) {
e.printStackTrace();
}
}
public Socket getSocket() {
return mSocket;
}
}
......@@ -9,7 +9,10 @@
package org.telegram.messenger;
import android.app.Application;
import android.content.Intent;
import org.telegram.io.SingletonSocket;
import org.telegram.service.SocketService;
import org.telegram.tgnet.ConnectionsManager;
public class ApplicationLoader extends Application {
......@@ -22,7 +25,8 @@ public class ApplicationLoader extends Application {
@Override
public void onCreate() {
super.onCreate();
SingletonSocket.getInstance().init();
startService(new Intent(this, SocketService.class));
ConnectionsManager.native_setJava(false);
......
package org.telegram.service;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.support.annotation.Nullable;
import android.util.Log;
import org.telegram.io.Constants;
import org.telegram.io.SingletonSocket;
import io.socket.emitter.Emitter;
/**
* Created by Ahmad Nemati on 1/17/19.
*/
public class SocketService extends Service implements Emitter.Listener {
@Override
public void onCreate() {
super.onCreate();
SingletonSocket.getInstance().getSocket().on(Constants.GET_JSON_FOR_PING, this);
SingletonSocket.getInstance().getSocket().connect();
}
@Nullable
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
return START_STICKY;
}
@Override
public void call(Object... args) {
if (args.length == 0) return;
Log.e("Received from server", String.valueOf(args.length));
}
}
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