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
Incidents
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
8c5e5fd7
Commit
8c5e5fd7
authored
Jul 02, 2018
by
Mat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hop
parent
eca08127
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
4 deletions
+12
-4
src/SocketBundle/Command/WsCommand.php
src/SocketBundle/Command/WsCommand.php
+3
-3
src/SocketBundle/Services/ChatHub.php
src/SocketBundle/Services/ChatHub.php
+9
-1
No files found.
src/SocketBundle/Command/WsCommand.php
View file @
8c5e5fd7
...
...
@@ -41,20 +41,20 @@ class WsCommand extends ContainerAwareCommand
{
$output
->
write
(
"Tentative de connexion au chat
\n
"
);
/*
// méthode 1
$server
=
IoServer
::
factory
(
new
HttpServer
(
new
WsServer
(
new
ChatHub
(
$this
->
getContainer
())
)
), 8088, '
ws://0.0.0.0/socket
'
),
8088
,
'
0.0.0.0
'
);
*/
/*
// méthode 2
$server = new App('0.0.0.0', 8088);
$server->route('/', new ChatHub($this->getContainer()));
*/
$server
->
run
();
...
...
src/SocketBundle/Services/ChatHub.php
View file @
8c5e5fd7
...
...
@@ -73,6 +73,14 @@ class ChatHub implements MessageComponentInterface
{
// TODO: Implement onClose() method.
echo
"Un utilisateur s'est déconnecté
\n
"
;
foreach
(
$this
->
clients
as
$key
=>
$client
)
{
if
(
$client
===
$conn
)
{
unset
(
$this
->
clients
[
$key
]);
}
}
}
/**
...
...
@@ -98,7 +106,7 @@ class ChatHub implements MessageComponentInterface
*/
function
onMessage
(
ConnectionInterface
$from
,
$msg
)
{
echo
"Le message
"
.
$msg
.
"
a été reçu
\n
"
;
echo
"Le message
'"
.
$msg
.
"'
a été reçu
\n
"
;
foreach
(
$this
->
clients
as
$client
)
{
$response
=
json_encode
([
...
...
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