Hello,
I want to fill a byte array, but this code does not work:
| packet |
packet := ByteArray streamContents: [:str |
str nextPut: 16r02; "TOSERVER_INIT"
nextPut: 28;
"SER_FMT_VER_HIGHEST_READ"
uint16: 0;
"NETPROTO_COMPRESSION_NONE"
uint16: 37;
"CLIENT_PROTOCOL_VERSION_MIN"
uint16: 38;
"LATEST_PROTOCOL_VERSION"
nextPutAll: 'Player'. "Player name"
].
packet contents
nor this variant:
| packet |
packet := OrderedCollection streamContents: [:str |
str nextPut: 16r02; "TOSERVER_INIT"
nextPut: 28;
"SER_FMT_VER_HIGHEST_READ"
uint16: 0;
"NETPROTO_COMPRESSION_NONE"
uint16: 37;
"CLIENT_PROTOCOL_VERSION_MIN"
uint16: 38;
"LATEST_PROTOCOL_VERSION"
nextPutAll: 'Player'. "Player name"
].
(ByteArray withAll: packet contents) inspect
Given the packet must to be filled with byte, short, double, string, what is
the best/neat way to prepare packet for datagram?
Thanks
Hilaire
-----
http://drgeo.eu
--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html