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
12ce64b3
Commit
12ce64b3
authored
Jul 02, 2018
by
Mat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ce qu'il faut pour que le serveur websocket puisse démarrer
parent
63b6c2d3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
1 deletion
+24
-1
src/SocketBundle/Command/WsCommand.php
src/SocketBundle/Command/WsCommand.php
+14
-1
src/SocketBundle/Services/ChatHub.php
src/SocketBundle/Services/ChatHub.php
+10
-0
No files found.
src/SocketBundle/Command/WsCommand.php
View file @
12ce64b3
...
...
@@ -9,6 +9,10 @@
namespace
SocketBundle\Command
;
use
Ratchet\Http\HttpServer
;
use
Ratchet\Server\IoServer
;
use
Ratchet\WebSocket\WsServer
;
use
SocketBundle\Services\ChatHub
;
use
Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand
;
use
Symfony\Component\Console\Input\InputInterface
;
use
Symfony\Component\Console\Output\OutputInterface
;
...
...
@@ -34,7 +38,16 @@ class WsCommand extends ContainerAwareCommand
*/
protected
function
execute
(
InputInterface
$input
,
OutputInterface
$output
)
{
$output
->
write
(
"Hello"
);
$output
->
write
(
"Tentative de connexion au chat"
);
$server
=
IoServer
::
factory
(
new
HttpServer
(
new
WsServer
(
new
ChatHub
(
$this
->
getContainer
())
)
),
8080
);
$server
->
run
();
//parent::execute($input, $output); // pas nécessaire ici
}
...
...
src/SocketBundle/Services/ChatHub.php
View file @
12ce64b3
...
...
@@ -10,6 +10,7 @@ namespace SocketBundle\Services;
use
Ratchet\ConnectionInterface
;
use
Ratchet\MessageComponentInterface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
class
ChatHub
implements
MessageComponentInterface
{
...
...
@@ -18,6 +19,15 @@ class ChatHub implements MessageComponentInterface
* et hop, il ajoute tout ce qui doit être implémenté
*/
private
$container
;
private
$clients
;
public
function
__construct
(
ContainerInterface
$_container
)
{
$this
->
container
=
$_container
;
$this
->
clients
=
array
();
}
/**
* When a new connection is opened it will be passed to this method
...
...
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