Support Overview


Client API Usage Examples

Upgrade Information


New Release History

You are here:   Visualware >   MyConnection Server >   Support >   Client API Usage Examples >   Setting the Session ID (SID), using a timer and hiding the applet

Setting the Session ID (SID), using a timer and hiding the applet

The example below allows the user to enter a session ID, which is used to identify the results in the database once the test has finished. Once the session ID has been submitted a test will start with a timer shown. The test applet is hidden and the results will appear once the test has finished.

NOTE: In the most recent Java release it is often necessary to "click" on an applet to permit its use. If the applet is hidden, like in this example, it may not load or run as expected. Click here to view the test applet so it can be allowed. Some browsers will show a ribbon near at the top of the page asking user to ALLOW. It shouldn't be necessary to click the link above if this occurs.

Enter Session ID:

Code Required

The code below just needs to be copied into a web page at the position the applet is to appear.

<!-- SID Table Starts -->
<div id="sidtable" style="display:block;">
<table cellspacing="5" cellpadding="0" align="center" width="700">
<td width="205" align="center" style="font-size:20px;">Enter Session ID:</td>
<td width="320" align="center" style="font-size:20px;"><input type="text" value="" id="sid" size="40"></td>
<td width="153" align="center" style="font-size:20px;"><input type="submit" value="Start Test" onClick="processSid()"></td>
<!-- SID Table Ends -->

<!-- Timer Table Starts -->
<div id="timer" style="display:none;">
<table cellspacing="5" cellpadding="0" align="center" width="300">
<td style="font-size:30px;" align="center">Minutes</td>
<td style="font-size:30px;" align="center">Seconds</td>
<td align="center"><div id="minutes" style="font-size:50px;">0</div></td>
<td align="center"><div id="seconds" style="font-size:50px;">0</div></td>
<!-- Timer Table Ends -->

<!-- test applet -->

<div id="testapplet">

<div id="results" style="display:none;"></div>

Copy and paste the entire code below into the opening <head></head> section of your page. This includes a basic timer function, a function that displays the results of the test in a table and lastly a function that adds commas to large numbers.

The URL in BLUE below will also require changing to the correct MyConnection Server installation.

NOTE: The last param tag has been truncated to fit this page, make sure this line is whole once pasted.

<script type="text/javascript">
var testtimer;
var seconds = -1;
var minutes = 0;
var chosensid = "";


function startTimer() {

if (seconds < 59 || seconds == -1) {
seconds = seconds+1;
else {
seconds = 0;
minutes = minutes+1;


document.getElementById('seconds').innerHTML = seconds;
document.getElementById('minutes').innerHTML = minutes;
window.testtimer = setTimeout(function(){startTimer()},1000);


// Function called when the test has completed
function passResults(mssid,detaillink,downspeed,upspeed,downqos,upqos,minrtt,avgrtt,rttconsistency,maxdelay,bandwidth,routespeed,forcedidle) {

document.getElementById('timer').innerHTML = "<b>Test Complete</b>";

downToKbps = addCommas(Math.round(downspeed/1000));
upToKbps = addCommas(Math.round(upspeed/1000));
bwToKbps = addCommas(Math.round(bandwidth/1000));
rtToKbps = addCommas(Math.round(routespeed/1000));

// Creates the results text
var emailbody = "";

emailbody += "<b>Speed Test Results</b><br><br>";
emailbody += "MSSID:" + mssid + "<br>";
emailbody += "<a href='" + mssid + "'>Database Report</a><br><br>";
emailbody += "Download Speed: " + downToKbps + " Kbps <br>";
emailbody += "Upload Speed: " + upToKbps + " Kbps <br>";
emailbody += "Download Consistency of Service: " + downqos + "% <br>";
emailbody += "Upload Consistency of Service: " + upqos + "% <br>";
emailbody += "Min RTT: " + minrtt + "ms <br>";
emailbody += "Avg RTT: " + avgrtt + "ms <br>";
emailbody += "RTT Consistency: " + rttconsistency + "% <br>";
emailbody += "Max Pause: " + maxdelay + "ms <br>";
emailbody += "Bandwidth: " + bwToKbps + " Kbps <br>";
emailbody += "Route Speed: " + rtToKbps + " Kbps <br>";
emailbody += "Forced Idle: " + forcedidle + "% <br>";

// Populates in innerHTML with results
document.getElementById("results").innerHTML = emailbody;

// Makes the DIV visible
document.getElementById("results").style.display = 'block';

// Function used to add commas
function addCommas(str){

var arr,int,dec;
str += '';

arr = str.split('.');
int = arr[0] + '';
dec = arr.length>1?'.'+arr[1]:'';

return int.replace(/(\d)(?=(\d{3})+$)/g,"$1,") + dec;

function processSid() {

chosensid = document.getElementById('sid').value;
document.getElementById('timer').style.display = 'block';
document.getElementById('sidtable').style.display = 'none';
document.getElementById('testapplet').innerHTML =

'<applet mayscript name="mcs" code="myspeedserver/applet/myspeed.class" archive="/myspeed/myspeed_s_8.jar,/myspeed/plugins_s_8.jar" codebase="" width="1" height="1">'+
'<param name="testspecid" value="-2">'+
'<param name="permissions" value="all-permissions">'+
'<param name="autostart" value="yes">'+
'<param name="sid" value="*' + chosensid + '">'+




MyConnection Server

Online Testing Portal

Visualware Products

Visual IP Trace


© Visualware Inc. 2017 - All Rights Reserved