socket?.on("myListener_1") { (data, ack) in
guard let dataInfo = data.first else { return }
}
The data looks like this :
(obvisously sentTime should be a Number instead of a String)
Why does the Socket.IO SDK do this false conversion ?????
(lldb) po data
▿ 1 element
▿ 0 : 2 elements
▿ 0 : 2 elements
- key : cmd
- value : showAction
▿ 1 : 2 elements
- key : params
▿ value : 3 elements
▿ 0 : 2 elements
- key : id
- value : 1cesesyzd-zb34-a213-82ad-a42b02dc2343f
▿ 1 : 2 elements
- key : id2
- value : 232346ss-1123-ad23-33da-addasdfdfdf223
▿ 2 : 2 elements
- key : sentTime
- value : 2021-12-01T11:27:14.785Z
The dataInfo looks like this :
(lldb) po dataInfo
▿ 2 elements
▿ 0 : 2 elements
- key : cmd
- value : showSlide
▿ 1 : 2 elements
- key : params
▿ value : 3 elements
▿ 0 : 2 elements
- key : id
- value : 1cesesyzd-zb34-a213-82ad-a42b02dc2343f
▿ 1 : 2 elements
- key : id2
- value : 232346ss-1123-ad23-33da-addasdfdfdf223
▿ 2 : 2 elements
- key : sentTime
- value : 2021-12-01T11:27:14.785Z
Below is a second example. This time, the date is returned correctly as a Number :
socket?.on("aSecondListener") { (data, ack) in
guard let dataInfo = data.first else { return }
}
(lldb) po data
▿ 1 element
▿ 0 : 2 elements
▿ 0 : 2 elements
- key : type
- value : UPDATE
▿ 1 : 2 elements
- key : test
▿ value : 1 element
▿ 0 : 3 elements
▿ 0 : 2 elements
- key : new
▿ value : 2 elements
▿ 0 : 2 elements
- key : username
- value : myself
▿ 1 : 2 elements
- key : roomId
- value : 12344565346
▿ 1 : 2 elements
- key : sentTime
- value : 1638359689915
▿ 2 : 2 elements
- key : socketId
- value : sdadfsa3a-dafsdf3234324
The dataInfo looks like this :
(lldb) po dataInfo
▿ 2 elements
▿ 0 : 2 elements
- key : type
- value : UPDATE
▿ 1 : 2 elements
- key : test
▿ value : 1 element
▿ 0 : 3 elements
▿ 0 : 2 elements
- key : new
▿ value : 2 elements
▿ 0 : 2 elements
- key : username
- value : myself
▿ 1 : 2 elements
- key : roomId
- value : 12344565346
▿ 1 : 2 elements
- key : sentTime
- value : 1638359689915
▿ 2 : 2 elements
- key : socketId
- value : sdadfsa3a-dafsdf3234324
This time the sentTime parameter is clearly a Number (and not a String like in the first example).
Why the arbitrary difference ????
It seems to me that the Array does it correctly - however the dictionary does not.
Could the mistake be somewhere inside SocketExtensions.swift ?????
My socket.IO server publishes Date-Fields (as Unix-Timestamp).
I have two different socket.IO listeners running.
One of them interpretes the Date-Field correctly as Int64 number.
However the other listener interpretes the Date-Field as a String.
BOTH SERVER PAYLOADS CLEARLY HAVE A UNIX-TIMESTAMP NUMBER IN THEIR PAYLOAD.
THE SOCKET.IO SDK MUST SOMEHOW MESS UP THE TYPE WHEN DECODING !
Why the arbitrary difference ?
Here is an example-1 of a published payload :
Here is my Swift-code that listens :
The
data
looks like this : (obvisouslysentTime
should be a Number instead of a String)Why does the Socket.IO SDK do this false conversion ?????
The
dataInfo
looks like this :Below is a second example. This time, the date is returned correctly as a Number :
Here the payload-2 coming from the server :
The
dataInfo
looks like this :This time the
sentTime
parameter is clearly a Number (and not a String like in the first example).Why the arbitrary difference ????
It seems to me that the Array does it correctly - however the dictionary does not.
Could the mistake be somewhere inside
SocketExtensions.swift
?????Help desperately needed!