In script below I try to open ten websocket connections to server:
var webscd=[];
function initweb(){
for (var c=0; c <10; c++){
webscd[c]=new WebSocket(wsadress);
webscd[c].onopen=function(evt){
var binary = new Uint8Array(2);
binary[0]=1;
binary[1]=2;
webscd[c].send(binary.buffer);
};
webscd[c].onclose=function(evt){};
webscd[c].onmessage=function(evt){};
webscd[c].onerror=function(evt){};
}
}
initweb();
But this script throws following error
'Uncaught TypeError: Cannot read property 'send' of undefined'
. What should i do?