package com.mogo.realtime.spi;

import com.mogo.realtime.api.IRealTimeProvider;
import com.mogo.realtime.entity.SocketReceiveDataProto3;

/**
 * RealTime Provider SPI 单例对象
 */
public class RealTimeProviderImp implements IRealTimeProvider {

    private static volatile RealTimeProviderImp sInstance = null;
    private final IRealTimeProvider mDelegate;

    public static RealTimeProviderImp getInstance() {
        if (sInstance == null) {
            synchronized (RealTimeProviderImp.class) {
                if (sInstance == null) {
                    sInstance = new RealTimeProviderImp();
                }
            }
        }
        return sInstance;
    }

    public RealTimeProviderImp() {
        mDelegate = RealTimeProviderDelegateManager.getInstance().getRealTimeProvider();
    }

    @Override
    public SocketReceiveDataProto3.SocketReceiveDataProto getLocationMsg() {
        if (mDelegate != null) {
           return mDelegate.getLocationMsg();
        }
        return null;
    }

}
