package main
import (
"fmt"
)
func (notifier *WebSocketNotifier) notify(userID uint, method ResponseMethod, resource interface{}) {
notifier.broadcastChannel <- &websocket.Message{
UserID: userID,
Data: &Response{
Method: method,
Data: resource,
Done: make(chan struct{}),
},
}
}
func (notifier *WebSocketNotifier) syncNotify(userID uint, method ResponseMethod, resource interface{}) chan struct{} {
message := &websocket.Message{
UserID: userID,
Data: &Response{
Method: method,
Data: resource,
Done: make(chan struct{}),
},
}
notifier.broadcastChannel <- message
return message.Done
// Or:
// <-message.Done
}
// Socker writer file.
...
if err := sendMessage(message); err != nil {
log...
}
close(message.Done)