Socket 인터페이스 테스트 도구(socket.io.js)





    
    Socket 



    
    
    
    $(function () {
        var myAction = {}, socket;

        var socketConfig = {
            token: 'Bearer ' + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ',
            task_id: '1250659e-aba9-11e8-91a6'
        };  

        $.extend(myAction, {
            initSocket: function () {
                socket = io("ws://192.168.10.59/vackbot");  //ip
            },
            getData: function () {
                if (socket.connected) {
                    socket.emit("get_tasks", {
                        token: socketConfig.token
                    });
                    socket.on("push_tasks", function(res) {
                        console.log(res);
                    });

                    socket.emit("getlog", {
                        token: socketConfig.token,
                        task_id: socketConfig.task_id,
                        direction: 'down',      //up, down  , 
                        log_time: null,         // , 1532249295
                        start_time: null,       // 
                        end_time: null,         // 
                        size: 10                // 
                    });
                    socket.on("logpush", function(res) {
                        console.log(res);
                    });  

                    // 
                    socket.emit("getlog", {
                        token: socketConfig.token,
                        task_id: socketConfig.task_id,
                        direction: 'down',                
                        log_time: 1535560351.844,         
                        start_time: null,                 
                        end_time: null,                   
                        size: 10                          
                    });   

                    // 
                    socket.emit("getlog", {
                        token: socketConfig.token,
                        task_id: socketConfig.task_id,
                        direction: 'up',                
                        log_time: 1535560351.844,         
                        start_time: 1535560332.681,                 
                        end_time: 1535560351.844,                   
                        size: 10                         
                    });   

                    // , 
                    socket.emit("getlog", {
                        token: socketConfig.token,
                        task_id: socketConfig.task_id,
                        direction: 'down',                
                        log_time: 1535560351.844,         
                        start_time: 1535560351.844,                 
                        end_time: 1535560353.463,                   
                        size: 10                         
                    });                                                                                
                } else {
                    setTimeout(myAction.getData, 500);
                }
            },  
        });

        var init = function () {
            myAction.initSocket();
            myAction.getData();
        }();
    })
    



좋은 웹페이지 즐겨찾기