Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "http"
- "websocket"
- "time"
- )
- func uiServer(s string) websocket.Handler {
- return func(ws *websocket.Conn) {
- fmt.Println(s)
- }
- }
- func detector(quit chan bool) {
- for {
- select {
- case <- quit:
- fmt.Println("bailing")
- default:
- time.Sleep(100000)
- }
- }
- }
- func main() {
- quit := make(chan bool)
- go detector(quit)
- http.Handle("/daemon", websocket.Handler(uiServer("test")))
- err := http.ListenAndServe(":7070", nil)
- if err != nil {
- fmt.Println("Failed to open ", err)
- }
- time.Sleep(1) // stupid unsed imports
- }
Add Comment
Please, Sign In to add comment