Exemplo n.º 1
0
 protected function privateMessage(User $user, $forId, $data)
 {
     $message = new Message();
     $message->user = $user;
     $message->for = User::find($forId);
     $message->datetime = new \DateTime();
     $message->data = $data;
     $message->save();
     $this->sendToUser($forId, Protocol::message($message));
     return $message;
 }
Exemplo n.º 2
0
 public function updateUser(Request $request)
 {
     $conn = $this->server->getClient($request->getUserId());
     if (null === $conn) {
         return $this->json(false, $request->get('callback'));
     } else {
         /** @var $user \ElfChat\Entity\User */
         $user = $conn->user;
         $user->refresh();
         $this->server->send(Protocol::userUpdate($user));
         return $this->json(true, $request->get('callback'));
     }
 }
Exemplo n.º 3
0
 /**
  * @Route("/synchronize", name="ajax_synchronize", methods="post")
  */
 public function synchronize()
 {
     $users = array();
     foreach (Online::users() as $online) {
         $users[] = $online->user->export();
     }
     return $this->app->json(Protocol::synchronize($users));
 }
Exemplo n.º 4
0
 public function log($text, $level = 'default')
 {
     $this->send(Protocol::log($text, $level));
 }
Exemplo n.º 5
0
 public function updateUser()
 {
     $this->send(Protocol::userUpdate($this->user));
 }