Close old SSE connections, push down type strings
This commit is contained in:
parent
e8d865d0ab
commit
4925fe4857
4 changed files with 42 additions and 4 deletions
14
api/event.go
14
api/event.go
|
|
@ -20,8 +20,20 @@ type ConnectionSSE struct {
|
|||
userID int
|
||||
}
|
||||
|
||||
type Message struct {
|
||||
Resource string `json:"resource"`
|
||||
Time time.Time `json:"time"`
|
||||
Type string `json:"type"`
|
||||
URI string `json:"uri"`
|
||||
}
|
||||
|
||||
func (c *ConnectionSSE) SendEvent(w http.ResponseWriter, m platform.Event) error {
|
||||
return send(w, m)
|
||||
return send(w, Message{
|
||||
Resource: m.Resource,
|
||||
Time: m.Time,
|
||||
Type: m.Type.String(),
|
||||
URI: m.URI,
|
||||
})
|
||||
}
|
||||
func (c *ConnectionSSE) SendHeartbeat(w http.ResponseWriter, t time.Time) error {
|
||||
return send(w, platform.Event{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue