<?php

namespace SHServ;

use \SHServ\Entities\Device;

class RequiredControlScriptsScope extends \SHServ\Middleware\ControlScripts implements \SHServ\Implements\ControlScriptsInterface {

	public function register_sync_map(): void { }

	public function register_events_handlers(): void {
		$this -> add_event_handler("online", function(Device $device, Array $data) {
			$device -> device_ip = $data["device_ip"];
			$device -> connection_status = "active";

			$device_info = $device -> device_api() -> get_about();
			if($device_info and isset($device_info["data"]) and $device_info["data"]) {
				$device -> firmware_version = $device_info["data"]["firmware_version"];
			}

			$device -> update();
		});
	}

	public function register_regular_scripts(): void { }

	public function register_actions_scripts(): void { }

}