java - What is different between writeBinaryMessage() and write() of Vert.x WebSocket? -
i'm working on server project using vert.x , serverwebsocket
class.
currently, project uses pump#pump()
, serverwebsocket#write()
methods send large binary data clients , works well. found serverwebsocket
has method send binary data, writebinarymessage()
.
the manual says:
writebinarymessage()
: data might written multiple frames if exceeds maximum websocket frame size
but think serverwebsocket#write()
sends data multiple parts pumping stream.
what difference between writebinarymessage()
, write()
?
writebinarymessage():
- writes (potentially large) piece of binary data connection. data might written multiple frames if exceeds maximum websocket frame size.
write()
- write data stream. data put on internal write queue, , write happens asynchronously. avoid running out of memory putting on write queue, check writestream.writequeuefull() method before writing. done automatically if using pump.
both returns same type of data , takes buffer type of parameter.
only difference both functions handle data internally different.
if want write big binary data, should use writebinarymessage(buffer data) , if send alot small messages dynamically should use async function write(buffer data)
see:
Comments
Post a Comment