Negotiate Lower Bandwidth / Higher Density Packets for Peers #428

Merged
erinn merged 5 commits from fastercwtch into master 2022-01-26 20:02:50 +00:00
1 changed files with 5 additions and 4 deletions
Showing only changes of commit ec6e025284 - Show all commits

View File

@ -48,7 +48,7 @@ func (pa *PeerApp) NewInstance() tapir.Application {
newApp.OnAuth = pa.OnAuth newApp.OnAuth = pa.OnAuth
newApp.OnClose = pa.OnClose newApp.OnClose = pa.OnClose
newApp.OnConnecting = pa.OnConnecting newApp.OnConnecting = pa.OnConnecting
newApp.version.Store(0x01) newApp.version.Store(Version1)
return newApp return newApp
} }
@ -72,12 +72,13 @@ func (pa *PeerApp) Init(connection tapir.Connection) {
// we are abusing the context here slightly by sending a "malformed" GetVal request. // we are abusing the context here slightly by sending a "malformed" GetVal request.
// as a rule cwtch ignores getval requests that it cannot deserialize so older clients will ignore this // as a rule cwtch ignores getval requests that it cannot deserialize so older clients will ignore this
// message. // message.
// version *must* be the first message sent to prevent race conditions for aut events fired on auth // version *must* be the first message sent to prevent race conditions for other events fired after-auth
// we send the message before we update the rest of the system // (e.g. getVal requests)
// as such, we send this message before we update the rest of the system
pa.SendMessage(model2.PeerMessage{ pa.SendMessage(model2.PeerMessage{
ID: event.ContextVersion, ID: event.ContextVersion,
Context: event.ContextGetVal, Context: event.ContextGetVal,
Data: []byte{Version1}, Data: []byte{Version2},
}) })
pa.OnAuth(connection.Hostname()) pa.OnAuth(connection.Hostname())