Esempio n. 1
0
 public function show(Request $request, $id)
 {
     $session = $this->sessionManager->read($id);
     if (is_null($session)) {
         return redirect('/');
     }
     if ($session->isPrivate()) {
         $password = \Session::get('session.' . $session->getId() . '.password', '');
         if (!$session->unlock($password)) {
             return redirect('/');
         }
     }
     $categories = new \App\Models\CategoryList($session);
     $token = array();
     $token['timestamp'] = time();
     $client = new \phpcent\Client(env('CENT_HOST'));
     $client->setSecret(env('CENT_SECRET'));
     $token['hash'] = $client->generateClientToken('', $token['timestamp']);
     if ($request->isXmlHttpRequest()) {
         return $session->getObjects();
     } else {
         return view('show', compact('categories', 'session', 'token'));
     }
 }
Esempio n. 2
0
 public function update($sessionId, $objects)
 {
     foreach ($objects as $object) {
         $gameObject = \App\Object::where('session_id', '=', $sessionId)->where('log', '=', $object['name'])->first();
         if (is_null($gameObject)) {
             continue;
         }
         // there is no status 0 - its a C!
         if ($object['status'] == '0' && !starts_with($object['name'], 'BMA')) {
             $object['status'] = 'C';
         }
         // status 9 means patrol for police which
         // means free on radio
         if ($object['status'] == '9') {
             $object['status'] = '1';
         }
         $client = new \phpcent\Client(env('CENT_HOST'));
         $client->setSecret(env('CENT_SECRET'));
         $client->publish($sessionId, ['payload' => $object, 'id' => $gameObject->id]);
         $gameObject->status = $object['status'];
         $gameObject->save();
     }
     return $sessionId;
 }