简体   繁体   中英

BOOMR.subscribe function is not being executed

Here's my code snippet

This is my form.html

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>

    <h1>Beer Selection Page</h1>
    <form method="post" action="SelectBeer.do">
        Select beer characteristics
        <p>
            Color: <select name="color" size="1">

                <option value="light">light</option>
                <option value="amber">amber</option>
                <option value="brown">brown</option>
                <option value="dark">dark</option>
            </select> <br>
            <br>
            <input type="submit" value="Submit Beer" >

    </form>

    <form action="BandwidthCalc.do">
        <br>
        <br>
        <input type="submit" value="Calculate Bandwidth" >
    </form>

</body>
</html>

Here is my BandwidthCalc.java servlet class

public class BandwidthCalc extends HttpServlet {

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{

        RequestDispatcher view = request.getRequestDispatcher("bandwidth.jsp");
        view.forward(request, response);

    }
}

This is my bandwidth.jsp file

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Bandwidth calculation</title>
</head>
<body>

    This is bandwidth page!! <br>
    <script src="./js/jquery-2.1.3.min.js" type="text/javascript"></script>
    <script src="./Boomerang/boomerang.js" type="text/javascript"></script>
    <script src="./js/testBeacon.js" type="text/javascript"></script>

    <div id="results">
    </div>

</body>
</html>

And here is my testBeacon.js file

var bw=null,be=null,lat=null,laterr=null;

BOOMR.init({
    user_ip: '127.0.0.1',

  });

    BOOMR.subscribe('before_beacon', function(o) {
var html = "", t_name, t_other, others = [];

        if(!o.t_other) o.t_other = "";

        for(var k in o) {
            if(!k.match(/^(t_done|t_other|bw|lat|bw_err|lat_err|u|r2?)$/)) {
                if(k.match(/^t_/)) {
                    o.t_other += "," + k + "|" + o[k];
                }
                else {
                    others.push(k + " = " + o[k]);
                }
            }
        }

        if(o.t_done) { html += "This page took " + o.t_done + " ms to load<br>"; }
        if(o.t_other) {
            t_other = o.t_other.replace(/^,/, '').replace(/\|/g, ' = ').split(',');
            html += "Other timers measured: <br>";
            for(var i=0; i<t_other.length; i++) {
                html += "&nbsp;&nbsp;&nbsp;" + t_other[i] + " ms<br>";
            }
        }
        if(o.bw) { html += "Your bandwidth to this server is " + parseInt(o.bw*8/1024) + "kbps (&#x00b1;" + parseInt(o.bw_err*100/o.bw) + "%)<br>"; }
        if(o.lat) { html += "Your latency to this server is " + parseInt(o.lat) + "&#x00b1;" + o.lat_err + "ms<br>"; }

        var r = document.getElementById('results');
        r.innerHTML = html;

        if(others.length) {
            r.innerHTML += "Other parameters:<br>";

            for(var i=0; i<others.length; i++) {
                var t = document.createTextNode(others[i]);
                r.innerHTML += "&nbsp;&nbsp;&nbsp;";
                r.appendChild(t);
                r.innerHTML += "<br>";

            }
        }
});

When I run this BOOMR.subscribe function is not being executed. I can't understand why? I already included Boomerang folder using link http://github.com/lognormal/boomerang/

You're using boomerang without any plugins, so it doesn't run. The readme file has the following text near the top:

You must include at least one plugin (it doesn't have to be rt) or else the beacon will never actually be called.

https://github.com/lognormal/boomerang/blob/master/README.md

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM