| | |
| | | speechSokt.onopen = function(e){onOpen(e);}; // 定义响应函数
|
| | | speechSokt.onclose = function(e){
|
| | | console.log("onclose ws!");
|
| | | speechSokt.close();
|
| | | //speechSokt.close();
|
| | | onClose(e);
|
| | | };
|
| | | speechSokt.onmessage = function(e){onMessage(e);};
|
| | |
| | | }
|
| | | };
|
| | |
|
| | | this.wsSend = function ( oneData,stop ) {
|
| | | this.wsSend = function ( oneData ) {
|
| | |
|
| | | if(speechSokt == undefined) return;
|
| | | if ( speechSokt.readyState === 1 ) { // 0:CONNECTING, 1:OPEN, 2:CLOSING, 3:CLOSED
|
| | |
|
| | | speechSokt.send( oneData );
|
| | | if(stop){
|
| | | setTimeout(speechSokt.close(), 3000 );
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | | };
|
| | |
| | | speechSokt.send( JSON.stringify(request) );
|
| | | console.log("连接成功");
|
| | | stateHandle(0);
|
| | | isconnected=1;
|
| | | |
| | | }
|
| | |
|
| | | function onClose( e ) {
|
| | |
| | | }
|
| | |
|
| | | function onError( e ) {
|
| | | isconnected=-1;
|
| | | |
| | | info_div.innerHTML="连接"+e;
|
| | | console.log(e);
|
| | | stateHandle(2);
|