java - Handle client disconnecting/closing the socket -
i writing chrome packaged application , using chrome.sockets
api. backend written in java.
when close socket in chrome app , check status, says has disconnected far packaged app concerned.
chrome.socket.disconnect(this.getsocketid()); chrome.socket.destroy(this.getsocketid());
however java backend doesn't throw error , blocked on reading. reading via gson
library think part of problem. whatever reason not able deal socket closing in instance. find bit odd test java client works fine , able disconnect fine.
if read via inputstreamreader.read()
result -1
according documentation indicates end of stream (i assume means knows sure socket closed).
jsonreader reader = new jsonreader(new inputstreamreader(socket.getinputstream(), "utf-8"))
// blocks @ call
jsonmessage message = gson.fromjson(reader,jsonmessage.class);
how handle disconnection in java application , still able read json messages?
Comments
Post a Comment