ghedipunk / PHP-Websockets

A Websockets server written in PHP.
BSD 3-Clause "New" or "Revised" License
913 stars 375 forks source link

How to send JSON #120

Open GaLaTaS opened 5 years ago

GaLaTaS commented 5 years ago

Hi, i'm trying to return a message to the client but in JSON type. I have try to json_encode the message but again the client received the MessageEvent.data as a text.

Thank you in advance

DrkAlien commented 5 years ago

Hi, can you please update us with some code lines and where did u wrote them ( what methods..etc ). Thanks.

GaLaTaS commented 5 years ago

Hi, i have create an array in frame function and json_encode it before the return.

$responseArray = array(...); $response = json_encode($responseArray); return chr($b1) . chr($b2) . $lengthField . $response;