fixed PlusROM data transmission

version number sent to server is taken from the 'new' versioning system
for the project (introduced since the last time the PlusROM network code
was looked at)

http logging flag moved to preferences system, instead of compile time flag
This commit is contained in:
JetSetIlly 2024-04-07 10:14:15 +01:00
parent 24f3f32342
commit 5d7551cf61
2 changed files with 16 additions and 6 deletions

View file

@ -24,6 +24,7 @@ import (
"github.com/jetsetilly/gopher2600/environment"
"github.com/jetsetilly/gopher2600/logger"
"github.com/jetsetilly/gopher2600/version"
)
const (
@ -78,10 +79,6 @@ func newNetwork(env *environment.Environment) *network {
}
}
// set to true to log HTTP repsonses/requests. this will do have to do until we
// implement logging levels.
const httpLogging = false
// add a single byte to the send buffer, capping the length of the buffer at
// the sendBufferCap value. if the "send" flag is true then the buffer is sent
// over the network. the function will not wait for the network activity.
@ -92,13 +89,13 @@ func (n *network) buffer(data uint8) {
func (n *network) commit() {
n.send.SendLen = n.send.WritePtr
n.send.WritePtr--
// the figure of 1024 is not accurate but it is sufficient to emulate the
// observed behaviour in the hardware. a realistic figure will be based on
// the system clock of the VCS and the baudrate of the PlusCart (which is
// 115200)
n.send.Cycles = int(n.send.WritePtr) * 1024
n.send.WritePtr--
}
func (n *network) transmitWait() {
@ -142,7 +139,8 @@ func (n *network) transmit() {
// The new "PlusROM-Info" header is discussed/explained in this AtariAge thread:
// https://atariage.com/forums/topic/324456-redesign-plusrom-request-http-header"
//
id := fmt.Sprintf("agent=Gopher2600; ver=0.17.0; id=%s; nick=%s",
id := fmt.Sprintf("agent=Gopher2600; ver=%s; id=%s; nick=%s",
version.Version,
// whether or not ID and Nick are valid has been handled in the preferences system
n.env.Prefs.PlusROM.ID.String(),
n.env.Prefs.PlusROM.Nick.String(),
@ -163,6 +161,9 @@ func (n *network) transmit() {
// logger.Logf("plusrom [net]", "PlusStore-ID: %s", id)
// -----------------------------------------------
// whether to log HTTP transactions taken from the global preferences
httpLogging := n.env.Prefs.PlusROM.HTTPLogging.Get().(bool)
// log of complete request
if httpLogging {
s, _ := httputil.DumpRequest(req, true)

View file

@ -35,6 +35,9 @@ type PlusROMPreferences struct {
// is true if the default nick/id are being used
NewInstallation bool
// show HTTP transactions in the log
HTTPLogging prefs.Bool
}
func newPlusROMpreferences() (*PlusROMPreferences, error) {
@ -61,6 +64,11 @@ func newPlusROMpreferences() (*PlusROMPreferences, error) {
return nil, err
}
err = p.dsk.Add("plusrom.httplogging", &p.HTTPLogging)
if err != nil {
return nil, err
}
err = p.Nick.Set("gopher2600")
if err != nil {
return nil, err
@ -124,6 +132,7 @@ func (p *PlusROMPreferences) generateID() string {
func (p *PlusROMPreferences) SetDefaults() {
p.Nick.SetMaxLen(plusnet.MaxNickLength)
p.ID.SetMaxLen(plusnet.MaxIDLength)
p.HTTPLogging.Set(false)
}
// Load plusrom preferences from disk.