31 lines
429 B
Go
31 lines
429 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"os"
|
||
|
|
||
|
"github.com/r3labs/sse/v2"
|
||
|
)
|
||
|
|
||
|
func main() {
|
||
|
println("Hello, World!")
|
||
|
|
||
|
device_id := os.Getenv("DEVICE_ID")
|
||
|
if device_id == "" {
|
||
|
println("DEVICE_ID env is not set")
|
||
|
os.Exit(1)
|
||
|
}
|
||
|
|
||
|
for {
|
||
|
client := sse.NewClient("https://ivampiresp.com/wp-content/rCMD/sse.php?device=" + device_id)
|
||
|
|
||
|
client.Subscribe("message", func(msg *sse.Event) {
|
||
|
fmt.Println(msg.Data)
|
||
|
|
||
|
// json
|
||
|
|
||
|
})
|
||
|
}
|
||
|
|
||
|
}
|