twitchapon

[Twi]tch [Cha]nnel [Po]ints Rewards Redemption Listener
git clone git://bsandro.tech/twitchapon
Log | Files | Refs | README | LICENSE

ping.go (385B)


      1 package main
      2 
      3 import (
      4 	"golang.org/x/net/websocket"
      5 	"time"
      6 )
      7 
      8 type TPingMsg struct {
      9 	MsgType string `json:"type"`
     10 }
     11 
     12 func OnPing() (interface{}, error) {
     13 	var res TPingMsg
     14 	res.MsgType = "PING"
     15 	return res, nil
     16 }
     17 
     18 func PingJob() {
     19 	for App.Connection != nil {
     20 		msg, _ := OnPing()
     21 		websocket.JSON.Send(App.Connection, msg)
     22 		time.Sleep(4 * time.Minute)
     23 	}
     24 
     25 	App.WaitGroup.Done()
     26 }