Example #1
0
 public function getHandler($conn)
 {
     Context::clear();
     $app = \Slim\Slim::getInstance();
     $credentials = $conn->WebSocket->request->getQuery()->toArray();
     //
     // Aparently, this doesn't work as expected.
     //
     // set x-auth-token
     if (isset($credentials['X-Auth-Token'])) {
         $app->request->headers->set('X-Auth-Token', $credentials['X-Auth-Token']);
         unset($credentials['X-Auth-Token']);
     }
     // remove "/" and possible "ws/" from resource path
     $resource = str_replace("ws/", "", substr($conn->WebSocket->request->getPath(), 1));
     $hash = md5($resource . join(",", array_values($credentials)));
     if (!isset($this->handlers[$hash])) {
         if ($key = Model\AppKey::where('app_id', $credentials['X-App-Id'])->where('key', $credentials['X-App-Key'])->first()) {
             Context::setKey($key);
             $channel = Model\Module::channel($resource);
             if ($channel) {
                 $this->handlers[$hash] = $channel->compile();
             }
         }
     }
     return isset($this->handlers[$hash]) ? $this->handlers[$hash] : null;
 }
Example #2
0
 public function create()
 {
     // Reset table prefix
     Context::setTablePrefix('');
     $data = Model\App::create(Input::get('app'));
     $response = $data->toArray();
     // Set application prefix for migration
     Context::setKey($data->keys[0]);
     Context::migrate();
     return $response;
 }