瀏覽代碼

Handle "not connected" errors

James 11 年之前
父節點
當前提交
ca6cfb1608
共有 1 個文件被更改,包括 4 次插入1 次删除
  1. 4 1
      stream-server.js

+ 4 - 1
stream-server.js 查看文件

@@ -35,7 +35,10 @@ socketServer.on('connection', function(socket) {
35 35
 
36 36
 socketServer.broadcast = function(data, opts) {
37 37
 	for( var i in this.clients ) {
38
-		this.clients[i].send(data, opts);
38
+		if (this.clients[i].readyState == 1)
39
+			this.clients[i].send(data, opts);
40
+		else
41
+			this.emit("error", "not connected");
39 42
 	}
40 43
 };
41 44