定制 rtckit/esl 二次开发

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

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

rtckit/esl

Composer 安装命令:

composer require rtckit/esl

包简介

FreeSWITCH Event Socket Layer (ESL) Library

README 文档

README

Build Status Latest Stable Version Test Coverage Maintainability License

Quickstart

FreeSWITCH's Event Socket Layer is a TCP control interface enabling the development of complex dynamic dialplans/workflows. You can learn more about its inbound mode as well as its outbound mode on the FreeSWITCH website.

This library provides an I/O agnostic implementation of the ESL protocol.

ESL Message Parsing

The authentication stage of an ESL connection can be summarized as follows:

/* This is a typical FreeSWITCH ESL server greeting */
$response = \RTCKit\ESL\Response::Parse("Content-Type: auth/request\n\n");

echo 'A server sends: ' . get_class($response) . PHP_EOL;

/* Since we've been told to authenticate, let's prepare our auth request */
$request = \RTCKit\ESL\Request::parse("auth ClueCon\n\n");

echo 'A client responds with: ' . get_class($request) . '; ';
echo 'password: ' . $request->getParameters() . PHP_EOL;

/* If our secret is correct, the ESL server should confirm that */
$followup = \RTCKit\ESL\Response::parse("Content-Type: command/reply\nReply-Text: +OK accepted\n\n");

echo 'Then the server replies with: ' . get_class($followup) . '; ';
echo ($followup->isSuccessful() ? 'Success!' : 'Yikes!') . PHP_EOL;

ESL Message Rendering

The reverse procedure, rendering to string, is straightforward:

$response = new \RTCKit\ESL\Response\AuthRequest;

echo 'A server sends: "' . $response->render() . '"' . PHP_EOL;

$request = new \RTCKit\ESL\Request\Auth;
$request->setParameters('ClueCon');

echo 'A client responds with: "' . $request->render() . '"' . PHP_EOL;

$followup = new \RTCKit\ESL\Response\CommandReply;
$followup->setHeader('reply-text', '+OK accepted');

echo 'Then the server replies with: "' . $followup->render() . '"' . PHP_EOL;

ESL Connection

Although this library is I/O independent, a Connection interface and base class are being provided; since ESL runs over TCP, a stream oriented transport, it behooves to handle the message framing in a higher level library. An implementing project would simply invoke the ConnectionInterface::consume() method when input is available and would implement a ConnectionInterface::emitBytes() method which performs the corresponding I/O-specific write operations.

The Connection constructor requires a $role argument, which must be one of the following:

  • ConnectionInterface::INBOUND_CLIENT to be used by ESL clients connecting to FreeSWITCH ESL servers;
  • ConnectionInterface::OUTBOUND_SERVER to be used by ESL servers FreeSWITCH connects to in outbound mode;

The other two options are less common:

  • ConnectionInterface::INBOUND_SERVER to impersonate a FreeSWITCH ESL server;
  • ConnectionInterface::OUTBOUND_CLIENT to impersonate FreeSWITCH connecting to a remote ESL endpoint in outbound mode;

The latter two roles can be useful in test suites, implementing message relays, security research etc. Please note the inbound and outbound terms are relative to the FreeSWITCH endpoint (matching the mod_event_socket nomenclature).

Requirements

RTCKit\ESL is compatible with PHP 7.4+ and has no external library and extension dependencies.

Installation

You can add the library as project dependency using Composer:

composer require rtckit/esl

If you only need the library during development, for instance when used in your test suite, then you should add it as a development-only dependency:

composer require --dev rtckit/esl

Tests

To run the test suite, clone this repository and then install dependencies via Composer:

composer install

Then, go to the project root and run:

composer phpunit

Static Analysis

In order to ensure high code quality, RTCKit\ESL uses PHPStan and Psalm:

composer phpstan
composer psalm

License

MIT, see LICENSE file.

Acknowledgments

  • FreeSWITCH, FreeSWITCH is a registered trademark of Anthony Minessale II

Contributing

Bug reports (and small patches) can be submitted via the issue tracker. Forking the repository and submitting a Pull Request is preferred for substantial patches.

rtckit/esl 适用场景与选型建议

rtckit/esl 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.41k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2022 年 01 月 15 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「telephony」 「freeswitch」 「esl」 「telco」 「event socket layer」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 rtckit/esl 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 rtckit/esl 我们能提供哪些服务?
定制开发 / 二次开发

基于 rtckit/esl 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-01-15