forked from cwtch.im/cwtch
More considered server side sync capability
This commit is contained in:
parent
f74e8647ef
commit
7c73df1f06
|
@ -39,7 +39,6 @@ func (ta *TokenboardServer) Init(connection tapir.Connection) {
|
|||
ta.AuthApp.Init(connection)
|
||||
if connection.HasCapability(applications.AuthCapability) {
|
||||
ta.connection = connection
|
||||
ta.connection.SetCapability(groups.CwtchServerSyncedCapability)
|
||||
go ta.Listen()
|
||||
} else {
|
||||
connection.Close()
|
||||
|
@ -85,6 +84,15 @@ func (ta *TokenboardServer) Listen() {
|
|||
data, _ = json.Marshal(message)
|
||||
ta.connection.Send(data)
|
||||
}
|
||||
newMessages := ta.LegacyMessageStore.FetchMessages()
|
||||
// Set sync and then send any new messages that might have happened while we were syncing
|
||||
ta.connection.SetCapability(groups.CwtchServerSyncedCapability)
|
||||
if len(newMessages) > len(messages) {
|
||||
for _, message := range newMessages[len(messages):] {
|
||||
data, _ = json.Marshal(groups.Message{MessageType: groups.NewMessageMessage, NewMessage: &groups.NewMessage{EGM: *message}})
|
||||
ta.connection.Send(data)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.Debugf("Server Closing Connection Because of Malformed ReplayRequestMessage Packet")
|
||||
ta.connection.Close()
|
||||
|
|
Loading…
Reference in New Issue