国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

gatewayworkerforwin 自定義協(xié)議,客戶端發(fā)送消息,服務端無法收到消息

workerman_99

具體問題

<?php
/**
 * This file is part of workerman.
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the MIT-LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @author    walkor<walkor@workerman.net>
 * @copyright walkor<walkor@workerman.net>
 * @link      http://wtbis.cn/
 * @license   http://www.opensource.org/licenses/mit-license.php MIT License
 */

namespace Protocols;
use Workerman\Connection\TcpConnection;

/**
 * jt808基礎分包
 */
class Jt808
{
    /**
     * Check the integrity of the package.
     *
     * @param string        $buffer
     * @return int
     */
    public static function input($buffer,TcpConnection $connection)
    {
        if (strlen($buffer) >= TcpConnection::$maxPackageSize) {
            $connection->close();
            return 0;
        }
        //尋找7e,除開開頭的7e,分包
        $buffer=strtolower($buffer);
        $pos = strpos($buffer, "7e",2);
        // No "\n", packet length is unknown, continue to wait for the data so return 0.
        if ($pos === false) {
            return 0;
        }
        // Return the current package length.
        return $pos + 2;
    }

    /**
     * Encode.
     * 替換字節(jié) 7d02=>7e 7d01=>7d
     * @param string $buffer
     * @return string
     */
    public static function encode($buffer)
    {
        $buffer=str_replace(pack("H*",'7d02'),pack('H*','7e'),$buffer);
        $buffer=str_replace(pack("H*",'7d01'),pack('H*','7d'),$buffer);
        return substr($buffer,1,-1);
    }

    /**
     * Decode.
     *
     * @param string $buffer
     * @return string
     */
    public static function decode($buffer)
    {
        // Remove "\n"
        return $buffer;
    }
}
2431 2 0
2個回答

小七他哥

看是不是防火墻屏蔽了

  • workerman_99 2021-07-09

    沒有啊,在協(xié)議 input 哪里都可以打印出來,但是到了 onmesssage 這里就沒有。

yongdao35

說明協(xié)議解析不對,或者客戶端傳的數(shù)據(jù)不符合協(xié)議。

年代過于久遠,無法發(fā)表回答
??