I'm trying to send a message with an object from the server to the client side socket event, but when I received the message in the client side, all keys with null values are not showing from the result. I'm using NettySocketIO
by the way in the server side.
Server Side:
@Override
@Scheduled(fixedDelay = 5000, initialDelay = 5000)
public void scheduledFindAllOrders() {
SocketMessage message = new SocketMessage();
List<Order> orders = this.repository.findAll();
message.setSender("SYSTEM");
message.setReceiver("ALL");
message.setMessage("Lis of orders.");
message.setData(orders);
//send to all clients
this.server.getBroadcastOperations().sendEvent("orders", message);
}
@Data
@Entity
@Table(name = TABLES.ORDER)
public class Order {
@Id
private Integer id;
private Integer transporterId;
......other keys
Client Side:
//socket-io v 2.2.0
const socket = io('http://localhost:8080', {
transports: ['polling', 'websocket']
});
socket.on('connect', function () {
console.log('Connected');
});
socket.on('orders', function (data) {
console.log('Received message', data);
});
I was expecting to get something like this
[{id: 1, transporterId: 2}, {id:2, transporterId: null}]
Instead I received this
[{id: 1, transporterId: 2}, {id:2}]
Is it a default in SocketIO client to strip away all object keys with null values? And if so is there any ways around this?
here conf is Configuration for web sockets