test
This commit is contained in:
parent
6ea3f77b62
commit
deb87dceed
1 changed files with 11 additions and 2 deletions
|
|
@ -188,10 +188,19 @@ func (manager *SocketManager) writeCloseRaw(writer WriterChan, message string) {
|
||||||
|
|
||||||
func (manager *SocketManager) writeTextRaw(writer WriterChan, event string, message string) {
|
func (manager *SocketManager) writeTextRaw(writer WriterChan, event string, message string) {
|
||||||
routine.DebugLongRunning("writeTextRaw", func() {
|
routine.DebugLongRunning("writeTextRaw", func() {
|
||||||
|
timeout := 3 * time.Second
|
||||||
|
data := ""
|
||||||
if event != "" {
|
if event != "" {
|
||||||
writer <- fmt.Sprintf("event: %s\ndata: %s\n\n", event, message)
|
data = fmt.Sprintf("event: %s\ndata: %s\n\n", event, message)
|
||||||
} else {
|
} else {
|
||||||
writer <- fmt.Sprintf("data: %s\n\n", message)
|
data = fmt.Sprintf("data: %s\n\n", message)
|
||||||
|
}
|
||||||
|
fmt.Printf("writing to channel:\n")
|
||||||
|
select {
|
||||||
|
case writer <- data:
|
||||||
|
fmt.Println("Sent to the channel")
|
||||||
|
case <-time.After(timeout):
|
||||||
|
fmt.Printf("could not send %s to channel after %s\n", data, timeout)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue