Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

能否支持 ws / wss 等协议? #756

Open
iwakura-lain opened this issue May 13, 2023 · 1 comment
Open

能否支持 ws / wss 等协议? #756

iwakura-lain opened this issue May 13, 2023 · 1 comment
Labels
feature good first issue Good for newcomers

Comments

@iwakura-lain
Copy link

在当前版本的基础上添加了官方的 websocket inject 示例脚本,启动时通过 -s 指定了该脚本。通过 log 可以打印出 websocket 信息,但是平台上 Inspector 和 Inspector Pro 都没有 websocket 信息,请问下能否支持 ws/wss 这类协议?或者能否提供一点修改思路,能够让 ws:// 被录制?十分感谢

@zhaoye
Copy link
Member

zhaoye commented May 16, 2023

在当前版本的基础上添加了官方的 websocket inject 示例脚本,启动时通过 -s 指定了该脚本。通过 log 可以打印出 websocket 信息,但是平台上 Inspector 和 Inspector Pro 都没有 websocket 信息,请问下能否支持 ws/wss 这类协议?或者能否提供一点修改思路,能够让 ws:// 被录制?十分感谢


简单的介绍一下思路:
可以参考插件开发相关的文档。实现一个自定义的ws服务,该服务上的数据可以作为事件写入Lyrebird eventbus。这样就可以在Inspector Pro上看到了。


插件开发相关文档

https://meituan-dianping.github.io/lyrebird/develop/plugin.html


向eventbus发送消息的方法

import lyrebird
lyrebird.publish

方法说明:

def publish(channel, event, *args, **kwargs):
"""
发送信号
:param signal: 信号,包含lyrebird, overbridge, android, tracking, perf, hunter
:param sender: 信号发送者标识
:param kwargs: 事件数据
:return:
"""
# context.application.event_bus.publish(channel, event)
application.server['event'].publish(channel, event, *args, **kwargs)


订阅eventbus中指定消息的方法

import lyrebird
lyrebird.subscribe

方法说明:

def subscribe(channel, func, *args, **kwargs):
"""
订阅信号
:param signal: 信号,包含lyrebird, overbridge, android, tracking, perf, hunter
:param func: 响应事件的回调函数
:param sender: 信号发送者标识
"""
# context.application.event_bus.subscribe(channel, func)
application.server['event'].subscribe(channel, func, *args, **kwargs)


@iwakura-lain 希望能帮到你

@zhaoye zhaoye added good first issue Good for newcomers feature labels May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants