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));
    }
}
