package com.czg.cashier_reserve.channel;

import com.czg.cashier_reserve.call.CallManager;

import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.common.MethodChannel;

public class MessageChannel {
	public static void addMessageChannel(BinaryMessenger messenger) {
		callLogChannel(messenger);
	}

	public static void callLogChannel(BinaryMessenger messenger) {
		if (messenger == null) {
			return;
		}

		MethodChannel methodChannel = new MethodChannel(messenger, ChannelNames.getChannelName(ChannelNames.GET_CALL_LOG));

		methodChannel.setMethodCallHandler((call, result) -> {
			System.out.println("call.method: " + call.method);
			if (call.method.equals(ChannelNames.GET_CALL_LOG)) {
				System.out.println("加载通话记录");
				result.success(null);
				CallManager.loadCallLog();
			};
		});
	}
}
