Tapir Server Refactor #317

Merged
dan merged 12 commits from tapir_server into master 2020-09-28 21:56:20 +00:00
1 changed files with 9 additions and 1 deletions
Showing only changes of commit 7c73df1f06 - Show all commits

View File

@ -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()