feat: distribute new local posts to followers via websocket
This commit is contained in:
parent
5c6da51234
commit
97b05d787f
6 changed files with 107 additions and 75 deletions
|
@ -5,10 +5,20 @@ import "encoding/json"
|
|||
type EventType int8
|
||||
|
||||
const (
|
||||
// Sent when an error occurs
|
||||
// Payload: {code:int, message:string}
|
||||
EventTypeError EventType = 1
|
||||
EventTypePost EventType = 2
|
||||
// Sent when echoing back received messages
|
||||
// Payload: <received message>
|
||||
EventTypeEcho EventType = 2
|
||||
// Sent on a new post being created
|
||||
// Payload: <post object>
|
||||
EventTypePost EventType = 3
|
||||
|
||||
EventTypeSubscribe EventType = 126
|
||||
// Receive events
|
||||
// Subscribe to a new event
|
||||
EventTypeSubscribe EventType = 126
|
||||
// Unsubscribe from an event
|
||||
EventTypeUnsubscribe EventType = 127
|
||||
)
|
||||
|
||||
|
@ -16,6 +26,8 @@ func (et EventType) Valid() bool {
|
|||
switch et {
|
||||
case EventTypeError:
|
||||
return true
|
||||
case EventTypeEcho:
|
||||
return true
|
||||
case EventTypePost:
|
||||
return true
|
||||
case EventTypeSubscribe:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue