mirror of
https://github.com/hoernschen/dendrite.git
synced 2024-12-29 08:18:27 +00:00
Start the unsent sending
This commit is contained in:
parent
c112c68d8e
commit
3f205b1dab
1 changed files with 39 additions and 0 deletions
|
@ -17,6 +17,7 @@ package input
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/common"
|
"github.com/matrix-org/dendrite/common"
|
||||||
"github.com/matrix-org/dendrite/roomserver/api"
|
"github.com/matrix-org/dendrite/roomserver/api"
|
||||||
|
@ -26,6 +27,44 @@ import (
|
||||||
"github.com/matrix-org/util"
|
"github.com/matrix-org/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type sendValue struct {
|
||||||
|
finishedChan chan<- struct{}
|
||||||
|
stateAtEvent types.StateAtEvent
|
||||||
|
event gomatrixserverlib.Event
|
||||||
|
sendAsServer string
|
||||||
|
transactionID *api.TransactionID
|
||||||
|
}
|
||||||
|
|
||||||
|
type EventSender struct {
|
||||||
|
db RoomEventDatabase
|
||||||
|
outputWriter OutputRoomEventWriter
|
||||||
|
sendingMutex sync.Mutex
|
||||||
|
sending map[types.RoomNID][]sendValue
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *EventSender) send(
|
||||||
|
ctx context.Context,
|
||||||
|
roomNID types.RoomNID,
|
||||||
|
stateAtEvent types.StateAtEvent,
|
||||||
|
event gomatrixserverlib.Event,
|
||||||
|
sendAsServer string,
|
||||||
|
transactionID *api.TransactionID,
|
||||||
|
) {
|
||||||
|
e.sendingMutex.Lock()
|
||||||
|
defer e.sendingMutex.Unlock()
|
||||||
|
|
||||||
|
finishedChan := make(chan struct{})
|
||||||
|
e.sending[roomNID] = append(e.sending[roomNID], sendValue{
|
||||||
|
finishedChan: finishedChan,
|
||||||
|
stateAtEvent: stateAtEvent,
|
||||||
|
event: event,
|
||||||
|
sendAsServer: sendAsServer,
|
||||||
|
transactionID: transactionID,
|
||||||
|
})
|
||||||
|
|
||||||
|
<-finishedChan
|
||||||
|
}
|
||||||
|
|
||||||
// updateLatestEvents updates the list of latest events for this room in the database and writes the
|
// updateLatestEvents updates the list of latest events for this room in the database and writes the
|
||||||
// event to the output log.
|
// event to the output log.
|
||||||
// The latest events are the events that aren't referenced by another event in the database:
|
// The latest events are the events that aren't referenced by another event in the database:
|
||||||
|
|
Loading…
Reference in a new issue