定制 notioncommotion/stream-parser 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

notioncommotion/stream-parser

Composer 安装命令:

composer create-project notioncommotion/stream-parser

包简介

Wrapper for socket stream. Adds deliminator and serializing.

README 文档

README

Wrapper for ReactPHP socket stream. Allows encoding using length prefix or character deliminator (not tested), or none (for testing only). Allows serializing using JSON or CBOR and if clientn communicates first will use that serializer.

Installation

Add notioncommotion/stream-parser as a requirement to composer.json:

{
    "require": {
       "notioncommotion/stream-parser": "^1.0"
    }
}
composer update

Usage

Server usage.

See the server example.

Values for the pem keys, and possibly others in config.client.ini will need to be update to reflect your requirements. Be sure that log file locations are writable.

Current available values for encoder are lengthprefix (tested), lengthprefix (not tested), and no (i.e. none which is only used for testing only). Current available values for serializer are JSON and CBOR.

ip                      =   0.0.0.0     ;Server listens on
port_tcp                =   1338        ;Leave blank to not use.
port_tls                =   1339        ;Leave blank to not use.
passphrase              =   ;optional key passphrase.  Uncomment if you use.
local_pk                =   /etc/pki/tls/private/sample-private-key.pem
local_cert              =   /etc/pki/tls/certs/sample-public-certificate.pem
local_pk_cert           =   /etc/pki/tls/private/sample-private-key-with-public-certificate.pem ;Both private key and public certificate
logMessages             =   0 ;If -1, do not log LengthPrefixStream, if value, log and crop, if zero, log and don't crop
summaryStreamLog        =   log/summary_stream.log ;If set, will write all read and write traphic to this file
rawReadStreamLog        =   log/raw_read_stream.log ;If set, will write all raw hex read traphic to this file
rawWriteStreamLog       =   log/raw_write_stream.log ;If set, will write all raw hex read traphic to this file
maxMessageLength        =   1000000     ;override for testing only.
encoder                 =   lengthprefix    ;lengthprefix/newline/no
serializers[]           =   cbor
serializers[]           =   json
$stream=new NotionCommotion\StreamParser\ServerStreamParser(
    React\Stream\DuplexStreamInterface $stream,
    NotionCommotion\StreamParser\Encoders\EncoderInterface $encoder,
    [NotionCommotion\StreamParser\Serializer\SerializerInterface $serializer],
    array $settings
);

To start the example server, using the following from the command line:

php server.php

Client usage.

See the client example.

Values for url, peer_name, the pem keys, and possibly others in config.client.ini will need to be update to reflect your requirements. Be sure that log file locations are writable.

Current available values for encoder are lengthprefix (tested), lengthprefix (not tested), and no (i.e. none which is only used for testing only). Current available values for serializer are JSON and CBOR.

url                     =   11.22.33.44
port                    =   1339            ;1338 is for TLS and 1339 is for TLS
peer_name               =   example.com
passphrase              =   ;optional key passphrase.  Uncomment if you use.
local_cert              =   /etc/pki/tls/certs/sample-public-certificate.pem    ;or ca
logMessages             =   0 ;If -1, do not log LengthPrefixStream, if value, log and crop, if zero, log and don't crop
summaryStreamLog        =   log/summary_stream.log ;If set, will write all read and write traphic to this file
rawReadStreamLog        =   log/raw_read_stream.log ;If set, will write all raw hex read traphic to this file
rawWriteStreamLog       =   log/raw_write_stream.log ;If set, will write all raw hex read traphic to this file
maxMessageLength        =   1000000 ;override for testing only
encoder                 =   lengthprefix   ;lengthprefix/newline/no
serializer              =   cbor   ;cbor/json
$stream=new NotionCommotion\StreamParser\StreamParser(
    React\Stream\DuplexStreamInterface $stream,
    NotionCommotion\StreamParser\Encoders\EncoderInterface $encoder,
    NotionCommotion\StreamParser\Serializer\SerializerInterface $serializer,
    array $settings
);

Be sure server is started first, and then start example client using the following from the command line:

php client.php

统计信息

  • 总下载量: 24
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2019-06-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固