-
Notifications
You must be signed in to change notification settings - Fork 324
Commit 703784f
authored
feat: add ping and pong received callbacks (#509)
This change adds two optional callbacks to both `DialOptions` and
`AcceptOptions`. These callbacks are invoked synchronously when a ping
or pong frame is received, allowing advanced users to log or inspect
payloads for metrics or debugging. If the callback needs to perform more
complex work or reuse the payload outside the callback, it is
recommended to perform processing in a separate goroutine.
The boolean return value of `OnPingReceived` is used to determine if the
subsequent pong frame should be sent. If `false` is returned, the pong
frame is not sent.
Fixes #246 1 parent aec630d commit 703784f
5 files changed
+135
-5
lines changedLines changed: 19 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
5 | 5 |
| |
6 | 6 |
| |
7 | 7 |
| |
8 | + | ||
8 | 9 |
| |
9 | 10 |
| |
10 | 11 |
| |
| |||
62 | 63 |
| |
63 | 64 |
| |
64 | 65 |
| |
66 | + | ||
67 | + | ||
68 | + | ||
69 | + | ||
70 | + | ||
71 | + | ||
72 | + | ||
73 | + | ||
74 | + | ||
75 | + | ||
76 | + | ||
77 | + | ||
78 | + | ||
79 | + | ||
80 | + | ||
81 | + | ||
65 | 82 |
| |
66 | 83 |
| |
67 | 84 |
| |
| |||
156 | 173 |
| |
157 | 174 |
| |
158 | 175 |
| |
176 | + | ||
177 | + | ||
159 | 178 |
| |
160 | 179 |
| |
161 | 180 |
| |
|
Lines changed: 11 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
83 | 83 |
| |
84 | 84 |
| |
85 | 85 |
| |
86 | - | ||
87 | - | ||
88 | - | ||
86 | + | ||
87 | + | ||
88 | + | ||
89 | + | ||
90 | + | ||
89 | 91 |
| |
90 | 92 |
| |
91 | 93 |
| |
| |||
94 | 96 |
| |
95 | 97 |
| |
96 | 98 |
| |
99 | + | ||
100 | + | ||
97 | 101 |
| |
98 | 102 |
| |
99 | 103 |
| |
| |||
114 | 118 |
| |
115 | 119 |
| |
116 | 120 |
| |
117 | - | ||
118 | - | ||
121 | + | ||
122 | + | ||
123 | + | ||
124 | + | ||
119 | 125 |
| |
120 | 126 |
| |
121 | 127 |
| |
|
Lines changed: 79 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
97 | 97 |
| |
98 | 98 |
| |
99 | 99 |
| |
100 | + | ||
101 | + | ||
102 | + | ||
103 | + | ||
104 | + | ||
105 | + | ||
106 | + | ||
107 | + | ||
108 | + | ||
109 | + | ||
110 | + | ||
111 | + | ||
112 | + | ||
113 | + | ||
114 | + | ||
115 | + | ||
116 | + | ||
117 | + | ||
118 | + | ||
119 | + | ||
120 | + | ||
121 | + | ||
122 | + | ||
123 | + | ||
124 | + | ||
125 | + | ||
126 | + | ||
127 | + | ||
128 | + | ||
129 | + | ||
130 | + | ||
131 | + | ||
132 | + | ||
133 | + | ||
134 | + | ||
135 | + | ||
136 | + | ||
137 | + | ||
138 | + | ||
139 | + | ||
140 | + | ||
141 | + | ||
142 | + | ||
143 | + | ||
144 | + | ||
145 | + | ||
146 | + | ||
147 | + | ||
148 | + | ||
149 | + | ||
150 | + | ||
151 | + | ||
152 | + | ||
153 | + | ||
154 | + | ||
155 | + | ||
156 | + | ||
157 | + | ||
158 | + | ||
159 | + | ||
160 | + | ||
161 | + | ||
162 | + | ||
163 | + | ||
164 | + | ||
165 | + | ||
166 | + | ||
167 | + | ||
168 | + | ||
169 | + | ||
170 | + | ||
171 | + | ||
172 | + | ||
173 | + | ||
174 | + | ||
175 | + | ||
176 | + | ||
177 | + | ||
178 | + | ||
100 | 179 |
| |
101 | 180 |
| |
102 | 181 |
| |
|
Lines changed: 18 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
48 | 48 |
| |
49 | 49 |
| |
50 | 50 |
| |
51 | + | ||
52 | + | ||
53 | + | ||
54 | + | ||
55 | + | ||
56 | + | ||
57 | + | ||
58 | + | ||
59 | + | ||
60 | + | ||
61 | + | ||
62 | + | ||
63 | + | ||
64 | + | ||
65 | + | ||
66 | + | ||
51 | 67 |
| |
52 | 68 |
| |
53 | 69 |
| |
| |||
163 | 179 |
| |
164 | 180 |
| |
165 | 181 |
| |
182 | + | ||
183 | + | ||
166 | 184 |
| |
167 | 185 |
| |
168 | 186 |
| |
|
Lines changed: 8 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
312 | 312 |
| |
313 | 313 |
| |
314 | 314 |
| |
315 | + | ||
316 | + | ||
317 | + | ||
318 | + | ||
319 | + | ||
315 | 320 |
| |
316 | 321 |
| |
322 | + | ||
323 | + | ||
324 | + | ||
317 | 325 |
| |
318 | 326 |
| |
319 | 327 |
| |
|
0 commit comments