When emitting a map of data that uses non-sequential numerical indexes, e.g.:
$data = [
"3" => "foo",
"7" => "bar"
];
$emitter = new SocketIO\Emitter();
$emitter->emit('event', $data);
The data is serialized, emitted, and received as an array, e.g.:
{
"0": "foo",
"1": "bar"
}
The only way around this right now is to add a non-numerical key into the map, e.g.:
$data = [
"3" => "foo",
"7" => "bar",
"hack" => true
];
$emitter->emit('event', $data);
The reason this is happening is because in this file (https://github.com/rase-/socket.io-php-emitter/blob/master/src/msgpack_pack.php#L79) starting at line 79, the code is converting the data to an array if all keys in the data are ints, regardless of if the keys are sequential or not.
When emitting a map of data that uses non-sequential numerical indexes, e.g.:
The data is serialized, emitted, and received as an array, e.g.:
The only way around this right now is to add a non-numerical key into the map, e.g.:
The reason this is happening is because in this file (https://github.com/rase-/socket.io-php-emitter/blob/master/src/msgpack_pack.php#L79) starting at line 79, the code is converting the data to an array if all keys in the data are ints, regardless of if the keys are sequential or not.