mirror of https://github.com/nealey/spongy
Finally enable push notification
This commit is contained in:
parent
b7f0d926fc
commit
b450b67d67
|
@ -43,6 +43,9 @@ input[name~=target] {
|
||||||
}
|
}
|
||||||
input[name~=text] {
|
input[name~=text] {
|
||||||
width: 75%;
|
width: 75%;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
height: 100%;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
33
irc.cgi.go
33
irc.cgi.go
|
@ -35,18 +35,29 @@ func tail(w http.ResponseWriter, pos int) {
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|
||||||
|
for {
|
||||||
_, err = f.Seek(int64(pos), 0)
|
printid := false
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
_, err = f.Seek(int64(pos), 0)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
bf := bufio.NewScanner(f)
|
||||||
|
for bf.Scan() {
|
||||||
|
t := bf.Text()
|
||||||
|
pos += len(t) + 1 // XXX: this breaks if we ever see \r\n
|
||||||
|
fmt.Fprintf(w, "data: %s\n", t)
|
||||||
|
printid = true
|
||||||
|
}
|
||||||
|
if printid {
|
||||||
|
_, err = fmt.Fprintf(w, "id: %d\n\n", pos)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
w.(http.Flusher).Flush()
|
||||||
|
time.Sleep(350 * time.Millisecond)
|
||||||
}
|
}
|
||||||
bf := bufio.NewScanner(f)
|
|
||||||
for bf.Scan() {
|
|
||||||
t := bf.Text()
|
|
||||||
pos += len(t) + 1 // XXX: this breaks if we ever see \r\n
|
|
||||||
fmt.Fprintf(w, "data: %s\n", t)
|
|
||||||
}
|
|
||||||
fmt.Fprintf(w, "id: %d\n\n", pos)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleCommand(w http.ResponseWriter, text string, target string) {
|
func handleCommand(w http.ResponseWriter, text string, target string) {
|
||||||
|
|
Loading…
Reference in New Issue