socket.io-android-chat
socket.io-android-chat copied to clipboard
Clear buffer after connect to server
how can i clear buffer after connect to server, when i disconnected from server and trying to emmit data, that buffered and after connect to server, this library send all buffered, this code, resolve my problem on web client
mySocket.on('connect', function () {
mySocket.sendBuffer=[]
console.log('Connected!');
});
+1 we need a way for clean the buffer, in my case the var mySocket.sendBuffer is private, i cant modify it.
private void onconnect() { this.connected = true; this.emit(EVENT_CONNECT); this.emitBuffered(); }
I see on reconnect, you will send receiveBuffer. How i can to clear receiveBuffer, because i don't want to send anything while socket reconnect? Thanks pro
I resolve it adding ID to every "package" i send, and the server reject it if exist
@juanmanuelarze could you take a sample?
just put an extra key with the ID (is a random string) in the object you emit and do the check in server
@juanmanuelarze could you take a sample?
+1 Need for clear buffer like nodejs socket.io-client.
When sending data with the "emit" command, it is possible that before the "on event" command runs, there will be a data buffer pending on the Android device side and make data "on event" to be executed twice when "socket on_connect" is called. So we want to be able to call "clear buffer" or clear the pending buffer if needed