2022-11-28 14:54:00 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
|
2022-12-06 09:35:57 +00:00
|
|
|
use App\Exceptions\EmqxSupportException;
|
2022-11-28 14:54:00 +00:00
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
use App\Support\EmqxSupport;
|
2022-12-06 09:35:57 +00:00
|
|
|
use Illuminate\Http\Client\ConnectionException;
|
2022-11-28 14:54:00 +00:00
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
class DeviceController extends Controller
|
|
|
|
{
|
|
|
|
//
|
|
|
|
|
|
|
|
public function index(Request $request)
|
|
|
|
{
|
|
|
|
$emqx = new EmqxSupport();
|
|
|
|
|
2022-12-06 09:35:57 +00:00
|
|
|
try {
|
|
|
|
$clients = $emqx->clients([
|
|
|
|
'clientid' => $request->client_id,
|
|
|
|
'username' => $request->username,
|
|
|
|
'page' => $request->page,
|
|
|
|
]);
|
|
|
|
} catch (EmqxSupportException|ConnectionException $e) {
|
|
|
|
return back()->with('error', $e->getMessage());
|
|
|
|
}
|
2022-11-28 14:54:00 +00:00
|
|
|
|
2022-11-28 15:14:48 +00:00
|
|
|
// dd($clients);
|
2022-11-28 14:54:00 +00:00
|
|
|
return view('admin.device.index', compact('clients'));
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// public function show(Request $request, $client_id)
|
|
|
|
// {
|
|
|
|
// $emqx = new EmqxSupport();
|
|
|
|
//
|
|
|
|
// $client = $emqx->clients(['clientid' => $client_id]);
|
|
|
|
//
|
|
|
|
// return view('admin.device.show', compact('client'));
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
public function destroy($client_id)
|
|
|
|
{
|
|
|
|
$emqx = new EmqxSupport();
|
|
|
|
|
|
|
|
$emqx->kickClient($client_id);
|
|
|
|
|
|
|
|
return back()->with('success', '此客户端已下线。');
|
|
|
|
}
|
|
|
|
}
|