跳转到主要内容

交互式连接建立(RFC 5245)的实现

项目描述

rtd pypi-v pypi-pyversions pypi-l pypi-wheel tests codecov

什么是 aioice

aioice 是一个用于 Python 的交互式连接建立(RFC 5245)的库。它建立在 Python 的标准异步 I/O 框架 asyncio 之上。

交互式连接建立(ICE)对于需要建立点对点 UDP 数据流的应用程序很有用,因为它简化了 NAT 穿越过程。典型用例包括 SIP 和 WebRTC。

要了解更多关于 aioice 的信息,请 阅读文档

示例

#!/usr/bin/env python

import asyncio
import aioice

async def connect_using_ice():
    connection = aioice.Connection(ice_controlling=True)

    # gather local candidates
    await connection.gather_candidates()

    # send your information to the remote party using your signaling method
    send_local_info(
        connection.local_candidates,
        connection.local_username,
        connection.local_password)

    # receive remote information using your signaling method
    remote_candidates, remote_username, remote_password = get_remote_info()

    # perform ICE handshake
    for candidate in remote_candidates:
        await connection.add_remote_candidate(candidate)
    await connection.add_remote_candidate(None)
    connection.remote_username = remote_username
    connection.remote_password = remote_password
    await connection.connect()

    # send and receive data
    await connection.sendto(b'1234', 1)
    data, component = await connection.recvfrom()

    # close connection
    await connection.close()

asyncio.get_event_loop().run_until_complete(connect_using_ice())

许可

aioice 采用 BSD 许可 发布。

项目详情


下载文件

下载适用于您平台的文件。如果您不确定该选择哪个,请了解有关安装包的更多信息。

源代码发行版

aioice-0.9.0.tar.gz (40.3 kB 查看哈希值)

上传时间 源代码

构建发行版

aioice-0.9.0-py3-none-any.whl (24.2 kB 查看哈希值)

上传时间 Python 3

支持者

AWSAWS 云计算和安全赞助商 DatadogDatadog 监控 FastlyFastly CDN GoogleGoogle 下载分析 MicrosoftMicrosoft PSF赞助商 PingdomPingdom 监控 SentrySentry 错误日志 StatusPageStatusPage 状态页面