}
const (
- agreementFile = "Agreement.txt"
+ agreementFile = "Agreement.txt"
)
// NewServer constructs a new Server from a config dir
defer s.mux.Unlock()
var connectedUsers []Field
- for _, c := range s.Clients {
+ for _, c := range sortedClients(s.Clients) {
user := User{
ID: *c.ID,
Icon: *c.Icon,
}
}
-
// sortedClients is a utility function that takes a map of *ClientConn and returns a sorted slice of the values.
// The purpose of this is to ensure that the ordering of client connections is deterministic so that test assertions work.
func sortedClients(unsortedClients map[uint16]*ClientConn) (clients []*ClientConn) {
Flags: &[]byte{0, 3},
UserName: []byte{0, 4},
},
+ uint16(2): {
+ ID: &[]byte{0, 2},
+ Icon: &[]byte{0, 2},
+ Flags: &[]byte{0, 3},
+ UserName: []byte{0, 4},
+ },
},
},
},
fieldUsernameWithInfo,
[]byte{00, 01, 00, 02, 00, 03, 00, 02, 00, 04},
),
+ NewField(
+ fieldUsernameWithInfo,
+ []byte{00, 02, 00, 02, 00, 03, 00, 02, 00, 04},
+ ),
},
},
},