I have been trying to to use pubnub in order to sent data stream through peers. What is happening though is that the message size on the one side is different from the one the other, though the number of messages sent and received are the same.What i have in mind is that by somehow part of the packets are lost
pubnub.publish({
channel: 'my_channel',
'message' : {
'packet': array_of_packets[counter_array_of_packets],
'which_packet_is': counter_array_of_packets,
'payload_size': calculate_payload_size('my_channel'array_of_packets[counter_array_of_packets])
}
callback : function(m){console.log(m)}
});
pubnub.subscribe({
channel: 'my_channel',
message: function(m){wait_(m)},
uuid: 'Mitsos',
error: function (error) {
// Handle error here
console.log(JSON.stringify(error));
}
});
The function used to calculate the size is:
function calculate_payload_size( channel, message ) {
return encodeURIComponent(
channel + JSON.stringify(message)
).length + 100;
}
So how can i use the above two functions publish and subscribe in a way that the TCP (reliable transmitting) is used? (if this can be of any help here is implemented a working example of pubnub - index.html where packets reach the right way the other side, though i can't seem to find if he uses tcp anywhere link)