I have been testing using a web-socket and want to use pingInterval to determine if the client has closed but I have been unable to detect that. I send a message over the websocket every 4 seconds. When I quit the browser no error condition is generated, I think, and I have not been able to figure out how to detect that the web-socket closed the connection. How can I detect that? I'm new at Dart and web applications as well.
解决方案
I tested it with SDK 1.5.0.dev:
Server code:
import 'dart:io';
main() {
HttpServer.bind('127.0.0.1', 4040).then((server) {
server.listen((HttpRequest request) {
WebSocketTransformer.upgrade(request).then((socket) {
socket.listen((msg){
socket.pingInterval = new Duration(seconds : 1);
print('server received message: $