public function getDequeueCommand() { $getResponse = function () { $result = CommandQueue::dequeue(); if ($result !== null) { return response()->json($result); } else { return null; } }; return $this->serveLongPolling($getResponse, response()->json(['commands' => 'empty'])); }
public function postEnqueueCommand(Request $request) { $input = $request->only(['command']); try { $success = CommandQueue::enqueue($input['command']); } catch (CommandParserException $e) { return $this->unableToParseJsonResponse($e->getMessage()); } if ($success) { return response()->json(['message' => 'command_enqueued_successfully']); } else { return $this->internalServerErrorJsonResponse('Unable to enqueue command correctly'); } }