coder / coder/websocket

Add custom ping message option to Ping function

未关闭
#441 1 条评论 4 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Go
星标
5.5k
派生
372
PR 合并指标
30 天内没有已合并 PR

描述

```
func (c *Conn) Ping(ctx context.Context) error {
p := atomic.AddInt32(&c.pingCounter, 1)

err := c.ping(ctx, strconv.Itoa(int(p)))
if err != nil {
return fmt.Errorf("failed to ping: %w", err)
}
return nil
}

func (c *Conn) ping(ctx context.Context, p string) error {
```

Is it possible to add a parameter to use custom ping/pong message when sending it? Sometimes, one side want to listen to specific ping/pong message. If we can add that, it would be very helpful.
I really like this project. It is simple enough that I can just focus my project logic.

贡献指南

这个仓库没有索引到贡献指南

调研方向

首先定位 Conn.Ping 以及 issue 中所示的内部 c.ping 函数,然后检查当前 ping payload 的生成方式,以及周围测试对它的覆盖情况。定义自定义消息 API,并更新相关行为,使调用方能够发送所请求的 ping/pong 消息,同时保留现有的默认行为。

由索引模型根据 Issue 内容生成。

评估

技术栈
go
领域
networking
Issue 类型
功能
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。