Files
desktop/app/providers/DeviceProvider/useDeviceResolve.ts

28 lines
792 B
TypeScript

import { PacketDeviceResolve, Solution } from "../ProtocolProvider/protocol/packets/packet.device.resolve";
import { useSender } from "../ProtocolProvider/useSender"
/**
* Хук для отклонения или принятия устройств
*/
export function useDeviceResolve() {
const send = useSender();
const accept = (deviceId: string) => {
const packet = new PacketDeviceResolve();
packet.setDeviceId(deviceId);
packet.setSolution(Solution.ACCEPT);
send(packet);
}
const decline = (deviceId: string) => {
const packet = new PacketDeviceResolve();
packet.setDeviceId(deviceId);
packet.setSolution(Solution.DECLINE);
send(packet);
}
return {
accept,
decline
}
}