php - flutter connection to ratchet websocket
Get the solution ↓↓↓I am trying to connect flutter app to PHP ratchet websocket. this socket work correctly in web with js WebSocket connection. in flutter i use web_socket_channel package and it can send message but it cant receive any message in listen function. my code:
channel = WebSocketChannel.connect(
Uri.parse('wss://aftablearn.com/ws'),
);
channel.stream.listen(
(message) {
print('message');
print(message);
},
onDone: () {
print("Web socket is closed");
},
onError: (error) {
print(error.toString());
},
);
Answer
Solution:
I'm not sure if you mean this: in Ratchet's documentation they show us this:
foreach ($this->clients as $client) {
if ($from !== $client) {
$client->send($msg);
}
}
this works like broadscast, cast to everyone except your device. try this:
foreach ($this->clients as $client) {
$client->send($msg);
}
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: foreign key constraint is incorrectly formed laravel
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.