Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
technobel.sf
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mathieu
technobel.sf
Commits
abbb06ba
Commit
abbb06ba
authored
Jul 05, 2018
by
Mat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chathub, le case /history
parent
b4ad93d7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
2 deletions
+21
-2
src/SocketBundle/Resources/views/Chat/usersHistory.html.twig
src/SocketBundle/Resources/views/Chat/usersHistory.html.twig
+2
-0
src/SocketBundle/Services/ChatHub.php
src/SocketBundle/Services/ChatHub.php
+19
-2
No files found.
src/SocketBundle/Resources/views/Chat/usersHistory.html.twig
0 → 100644
View file @
abbb06ba
src/SocketBundle/Services/ChatHub.php
View file @
abbb06ba
...
...
@@ -105,7 +105,8 @@ class ChatHub implements MessageComponentInterface
*
* @param \Ratchet\ConnectionInterface $from The socket/connection that sent the message to your application
* @param string $msg The message received
* @throws \Exception
* @return string
* @throws \Twig\Error\Error
*/
function
onMessage
(
ConnectionInterface
$from
,
$msg
)
{
...
...
@@ -134,11 +135,27 @@ class ChatHub implements MessageComponentInterface
break
;
case
'/history'
:
// récupère le destinataire
$dest
=
$data
->
dest
;
// appelle getUser
$username
=
$this
->
getUser
(
$token
);
// récupère l'historique des messages entre les 2 utilisateurs
$messageRepo
=
$this
->
getDoctrine
()
->
getManager
()
->
getRepository
(
Message
::
class
);
$messageRepo
->
$messages
=
$messageRepo
->
getHistory
(
$username
,
$dest
);
// passe l'historique dans le fragment twig
$twig
=
$this
->
container
->
get
(
'templating'
);
$fragment
=
$twig
->
render
(
'@Socket/Chat/usersHistory.html.twig'
,
array
(
'messages'
=>
$messages
));
// retourne le fragment en json
return
json_encode
(
array
(
'action'
=>
'refreseh_messages'
,
'view'
=>
$fragment
));
break
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment