oop - Error with a simple javascript prototype -


can me?

i tried code :

function network(ip, port){     this.socket = new websocket('ws://' + ip + ':' + port);     this.socket.onopen = function(){         console.log('connected');         this.send('test');     } } network.prototype = {      sendmessage : function(data){         this.socket.send(data);         alert(data);     } }  $(document).ready(function() {     window.network = new network('localhost', '8887');     window.network.sendmessage("hello, world!"); }); 

but when launch " uncaught error: invalidstateerror: dom exception 11 ". googled more 1 hour , didn't find something...

on server :

0:0:0:0:0:0:0:1%0 entered room! org.java_websocket.websocketimpl@584fce71: test 

so, problem in sendmessage function.. can me ? ! :)

websocket async function. please wait connected success sendmessage.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -