package com.app.duck.util;

import static com.app.duck.util.WsManager.sendWebSocketMsg;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

import com.elvishew.xlog.XLog;

import java.util.Set;

/**
 * author: hx
 * created on: 2024/4/13 21:02
 * description:
 */
public class SmsSentReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        int resultCode = getResultCode();
        Log.d("hzshkj", "SmsSentReceiver: " + resultCode);
        String requestId = intent.getStringExtra("requestId");
        String phone = intent.getStringExtra("phone");
        String content = intent.getStringExtra("content");


        if (resultCode == Activity.RESULT_OK) {
            long smsId = intent.getLongExtra("messageId", -1);
            XLog.i("sendSMS : " + "Start sending text messages......[mobile:" + phone + ",content:" + content + "]");
            Log.d("hzshkj", "[WsManager] sendSMS: " + "Start sending text messages......[mobile:" + phone + ",content:" + content + "]");
            sendWebSocketMsg(requestId, "successful", "RESULT_OK,smsId: +" + smsId + " ,mobile:" + phone + " ,content:" + content);

        } else {
            XLog.i("error,SmsSentReceiver!", resultCode);
            Log.d("hzshkj", "SmsSentReceiver: " + resultCode);
            sendWebSocketMsg(requestId, "exception", "resultCode:" + resultCode);
        }
    }


}
