googollee / go-socket.io

socket.io library for golang, a realtime application framework.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to add a PING listener

SebastienMelki opened this issue · comments

I am porting an implementation of a socketIO server from Kotlin to Go. Been tinkering with this repo for a few days and it's working out quite well. A feature in our current implementation relies on being able to detect ping events from clients.

I can't seem to find any way of adding a listener to the ping event using this package. I'm specifically looking for something like .OnPing(), similar to the available .OnConnect().

Is there a way to achieve this currently? If not could somebody point me to a part of the code where I could possibly implement such a functionality? I'll happily submit a PR. Thank you!

I found this part of the code in engineio/session/session.go which seem to be the ping handling. Any easy way to add a listener to this?

image

It seems like NextReader() in session.go has a side effect of responding with the PONGs. Makes it a bit hard to tap into it to expose it on a higher level. Is there a better way to tackle it?