Documentation ¶
Index ¶
- Constants
- Variables
- type ConnState
- func (s *ConnState) Alive() bool
- func (s *ConnState) Destroy()
- func (s *ConnState) OnIncomingRequest(ctx context.Context, cid sync3.ConnID, req *sync3.Request, isInitial bool) (*sync3.Response, error)
- func (s *ConnState) OnRoomUpdate(up caches.RoomUpdate)
- func (s *ConnState) OnUpdate(up caches.Update)
- func (s *ConnState) UserID() string
- type JoinChecker
- type SyncLiveHandler
- func (h *SyncLiveHandler) Accumulate(roomID, prevBatch string, timeline []json.RawMessage)
- func (h *SyncLiveHandler) AddToDeviceMessages(userID, deviceID string, msgs []json.RawMessage)
- func (h *SyncLiveHandler) Initialise(roomID string, state []json.RawMessage)
- func (h *SyncLiveHandler) OnAccountData(userID, roomID string, events []json.RawMessage)
- func (h *SyncLiveHandler) OnInvite(userID, roomID string, inviteState []json.RawMessage)
- func (h *SyncLiveHandler) OnRetireInvite(userID, roomID string)
- func (h *SyncLiveHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (h *SyncLiveHandler) SetTyping(roomID string, userIDs []string)
- func (h *SyncLiveHandler) Teardown()
- func (h *SyncLiveHandler) UpdateDeviceSince(deviceID, since string)
- func (h *SyncLiveHandler) UpdateUnreadCounts(roomID, userID string, highlightCount, notifCount *int)
Constants ¶
const DefaultSessionID = "default"
Variables ¶
var ( // The max number of events the client is eligible to read (unfiltered) which we are willing to // buffer on this connection. Too large and we consume lots of memory. Too small and busy accounts // will trip the connection knifing. MaxPendingEventUpdates = 200 )
Functions ¶
This section is empty.
Types ¶
type ConnState ¶
type ConnState struct {
// contains filtered or unexported fields
}
ConnState tracks all high-level connection state for this connection, like the combined request and the underlying sorted room list. It doesn't track positions of the connection.
func NewConnState ¶
func NewConnState( userID, deviceID string, userCache *caches.UserCache, globalCache *caches.GlobalCache, ex extensions.HandlerInterface, joinChecker JoinChecker, ) *ConnState
func (*ConnState) OnIncomingRequest ¶
func (s *ConnState) OnIncomingRequest(ctx context.Context, cid sync3.ConnID, req *sync3.Request, isInitial bool) (*sync3.Response, error)
OnIncomingRequest is guaranteed to be called sequentially (it's protected by a mutex in conn.go)
func (*ConnState) OnRoomUpdate ¶
func (s *ConnState) OnRoomUpdate(up caches.RoomUpdate)
Called by the user cache when updates arrive
type JoinChecker ¶
type SyncLiveHandler ¶
type SyncLiveHandler struct { V2 sync2.Client Storage *state.Storage V2Store *sync2.Storage PollerMap *sync2.PollerMap ConnMap *sync3.ConnMap Extensions *extensions.Handler Dispatcher *sync3.Dispatcher GlobalCache *caches.GlobalCache // contains filtered or unexported fields }
This is a net.http Handler for sync v3. It is responsible for pairing requests to Conns and to ensure that the sync v2 poller is running for this client.
func NewSync3Handler ¶
func (*SyncLiveHandler) Accumulate ¶
func (h *SyncLiveHandler) Accumulate(roomID, prevBatch string, timeline []json.RawMessage)
Called from the v2 poller, implements V2DataReceiver
func (*SyncLiveHandler) AddToDeviceMessages ¶
func (h *SyncLiveHandler) AddToDeviceMessages(userID, deviceID string, msgs []json.RawMessage)
Called from the v2 poller, implements V2DataReceiver Add messages for this device. If an error is returned, the poll loop is terminated as continuing would implicitly acknowledge these messages.
func (*SyncLiveHandler) Initialise ¶
func (h *SyncLiveHandler) Initialise(roomID string, state []json.RawMessage)
Called from the v2 poller, implements V2DataReceiver
func (*SyncLiveHandler) OnAccountData ¶
func (h *SyncLiveHandler) OnAccountData(userID, roomID string, events []json.RawMessage)
func (*SyncLiveHandler) OnInvite ¶
func (h *SyncLiveHandler) OnInvite(userID, roomID string, inviteState []json.RawMessage)
func (*SyncLiveHandler) OnRetireInvite ¶
func (h *SyncLiveHandler) OnRetireInvite(userID, roomID string)
func (*SyncLiveHandler) ServeHTTP ¶
func (h *SyncLiveHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)
func (*SyncLiveHandler) SetTyping ¶
func (h *SyncLiveHandler) SetTyping(roomID string, userIDs []string)
Called from the v2 poller, implements V2DataReceiver
func (*SyncLiveHandler) Teardown ¶ added in v0.1.1
func (h *SyncLiveHandler) Teardown()
used in tests to close postgres connections
func (*SyncLiveHandler) UpdateDeviceSince ¶
func (h *SyncLiveHandler) UpdateDeviceSince(deviceID, since string)
Called from the v2 poller, implements V2DataReceiver
func (*SyncLiveHandler) UpdateUnreadCounts ¶
func (h *SyncLiveHandler) UpdateUnreadCounts(roomID, userID string, highlightCount, notifCount *int)