This commit is contained in:
poiuty 2023-05-11 00:43:02 +03:00
parent 9fe159f6f3
commit 12e5ac6f68
5 changed files with 242 additions and 0 deletions

26
server/main.go Normal file
View file

@ -0,0 +1,26 @@
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))
}