mirror of
https://github.com/statbate/supreme-disco.git
synced 2026-08-11 03:22:41 +00:00
26 lines
396 B
Go
26 lines
396 B
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"net"
|
|
"net/http"
|
|
"os"
|
|
)
|
|
|
|
func main() {
|
|
|
|
go broadcast()
|
|
go startSocket()
|
|
|
|
http.HandleFunc("/ws/", wsHandler)
|
|
|
|
const SOCK = "/tmp/ws.sock"
|
|
removeSocket(SOCK)
|
|
unixListener, err := net.Listen("unix", SOCK)
|
|
if err != nil {
|
|
log.Fatal("Listen (ws socket): ", err)
|
|
}
|
|
defer unixListener.Close()
|
|
os.Chmod(SOCK, 0777)
|
|
log.Fatal(http.Serve(unixListener, nil))
|
|
}
|