feat: adding ping & pong handler

This commit is contained in:
2026-02-01 19:05:33 +07:00
parent 9816426780
commit 7f21b733ed
4 changed files with 33 additions and 22 deletions

View File

@@ -8,10 +8,18 @@ import (
"os/signal"
"syscall"
"net/http"
_ "net/http/pprof"
"git.neurocipta.com/rogerferdinan/safe-web-socket/v1/client"
)
func main() {
go func() {
log.Println("Starting pprof server on :6060")
log.Println(http.ListenAndServe(":6060", nil))
}()
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)

View File

@@ -19,7 +19,7 @@ func main() {
BasePort(8080).
ApiKey("abcd").
HandleFuncWebsocket("/ws/test/", "data_1", func(c chan []byte) {
ticker := time.NewTicker(10 * time.Millisecond)
ticker := time.NewTicker(100 * time.Millisecond)
for range ticker.C {
jsonBytes, err := json.Marshal(ExampleData{
Time: time.Now(),
@@ -32,7 +32,7 @@ func main() {
}
}).
HandleFuncWebsocket("/ws/test/", "data_2", func(c chan []byte) {
ticker := time.NewTicker(10 * time.Millisecond)
ticker := time.NewTicker(100 * time.Millisecond)
for range ticker.C {
jsonBytes, err := json.Marshal(ExampleData{
Time: time.Now(),