浏览代码

fixed missing null check (close #992)

Nicolas Cannasse 4 年之前
父节点
当前提交
96e10dfac3
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      hxd/net/SocketHost.hx

+ 2 - 2
hxd/net/SocketHost.hx

@@ -94,7 +94,7 @@ class SocketHost extends NetworkHost {
 		socket.onError = function(msg) {
 			if( !connected ) {
 				socket.onError = function(_) { };
-				onConnect(false);
+				if( onConnect != null ) onConnect(false);
 			} else
 				throw msg;
 		};
@@ -103,7 +103,7 @@ class SocketHost extends NetworkHost {
 			connected = true;
 			if( host == "127.0.0.1" ) enableSound = false;
 			clients = [self];
-			onConnect(true);
+			if( onConnect != null ) onConnect(true);
 		});
 	}