|
- if (socket!=null&&loginid!=""&&loginid!=undefined&&loginid!=null) {
- socket.createSocket({
- type: 'tcp',
- host: '192.168.14.42',
- port: 2345
- }, function(ret, err) {
- sid=ret.sid;
- console.log("建立连接");
- console.log(JSON.stringify(ret));
- if (ret.state==101||ret.state==102||ret.state==103) {
- if (ret.state==102) {
- api.sendEvent({
- name: 'online',
- extra: {
- online: true
- }
- });
- palyer_end_num=0;
- playerFunc("widget://res/start.mp3")
- clearInterval(socketTimer);
- messagerTimer = setInterval(function() {
- var pingdata=JSON.stringify({"type":"ping","loginid":loginid});
- console.log(pingdata);
- if(socket!=null){
- socket.write({
- sid: sid,
- data: pingdata
- }, function(ret, err) {
- });
- }
- }, 5000);
- }else if(ret.statte==103){
- onmessages(ret.data);
- }
- }
复制代码 |
|