header('Content-type: application/json;charset=utf-8');
use \GatewayWorker\Lib\Gateway;
use \GatewayWorker\Lib\Db;
class Events
{
public static function onConnect($client_id)
{
echo"client:{$_SERVER['REMOTE_ADDR']}:{$_SERVER['REMOTE_PORT']} gateway1:{$_SERVER['GATEWAY_ADDR']}:{$_SERVER['GATEWAY_PORT']} client_id:$client_id\n";
}
public static function onMessage($client_id, $message){
$db = Db::instance('db');
echo "client:{$_SERVER['REMOTE_ADDR']}:{$_SERVER['REMOTE_PORT']}
gateway2:{$_SERVER['GATEWAY_ADDR']}:{$_SERVER['GATEWAY_PORT']} $message\n";
json需要utf-8编码,文件编码和网页编码改成utf-8试下。
<?php
header('Content-type: application/json;charset=utf-8');
use \GatewayWorker\Lib\Gateway;
use \GatewayWorker\Lib\Db;
class Events
{
public static function onConnect($client_id)
{
echo"client:{$_SERVER['REMOTE_ADDR']}:{$_SERVER['REMOTE_PORT']} gateway1:{$_SERVER['GATEWAY_ADDR']}:{$_SERVER['GATEWAY_PORT']} client_id:$client_id\n";
}
public static function onMessage($client_id, $message){
$db = Db::instance('db');
echo "client:{$_SERVER['REMOTE_ADDR']}:{$_SERVER['REMOTE_PORT']}
gateway2:{$_SERVER['GATEWAY_ADDR']}:{$_SERVER['GATEWAY_PORT']} $message\n";
好像还不行 gateway2:{$_SERVER['GATEWAY_ADDR']}:{$_SERVER['GATEWAY_PORT']} $message\n"; 中文就是不显示 如果是其他字符就可以,或者吧中文转成unicode编码 也可以,就是纯中文死活不显示
{"method":"svsice","Device_ID":"232323233","voicetext":"你好"}
解决了谢谢