Review: BrowserHawk 9
page 4 of 6
by Steven Smith
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 30459/ 104

One More Scenario

Let's say you're working on a web site that requires a minimum connection of 30kb/second from your user, a large screen size (1024x768 minimum), and Flash 6 or higher so you can deliver a really cool multiplayer game (or interactive chat, desktop sharing app, or whatever).  As part of the application, you test the user's browser and connection speed to determine if they meet your minimum requirements.  Doing so with a single C# page would look something like this:

         

Figure 1: Minimum Requirements Not Met

With the requirements met, of course, the site would return a positive message and a link to the game.  Listing 3 shows the code required, all in one ASPX page for simplicity.

Listing 3 - Determining Minimum System Requirements Using BrowserHawk

<%@ Page language="c#" %>
<%@ Import Namespace="cyScape.BrowserHawk"
%>
<%
ExtendedOptions options = new ExtendedOptions();
options.AddProperties("Plugin_Flash");
options.AddProperties("ConnectionSpeed");
options.AddProperties("Height");
options.AddProperties("Width");
// note these 4 lines can all be done in 
// ExtendedOptions constructor in you prefer
 
ExtendedBrowserObj extBrow = BrowserObj.GetExtendedBrowser(options);
BrowserObj browObj =  BrowserObj.GetBrowser(); 
 
bool meetsRequirements = true;
 
// Detect Flash Settings
int flashVersion = extBrow.Plugin_Flash;
string flashResult = "True (" + flashVersion.ToString() + ")";
if(flashVersion < 6)
{
  flashResult = "False - Please Install Flash";
  meetsRequirements = false;
}
 
// Detect Screen Size
int height = extBrow.Height;
string heightResult = "True (" + height.ToString() + ")";
if(height < 768)
{
  heightResult = "False - (" + height.ToString() + ")";
  meetsRequirements = false;
}
int width = extBrow.Width;
string widthResult = "True (" + width.ToString() + ")";
if(width < 768)
{
  widthResult = "False - (" + width.ToString() + ")";
  meetsRequirements = false;
}
 
// detect connection speed
double speed = (double)extBrow.ConnectionSpeed;
string speedResult = "True (" + System.Math.Round((speed/1024),0) + " kb)";
if(speed < 30*1024)
{
  speedResult = "False (" + System.Math.Round((speed/1024),0) + " kb)";
  meetsRequirements = false;
}
 
string meetsRequirementsMessage = "Your system meets the minimum requirements!";
if(!meetsRequirements)
{
  meetsRequirementsMessage = "Sorry, your system does not meet the minimum requirements to play.";
}
%>
<html><title>Detect Minimum Requirements</title></head>
<body>
<h1>Detecting Minimum Requirements</h1>
<b><%=meetsRequirementsMessage%></b>
<ul>
  <li>Flash Installed (6 or higher?): <%=flashResult %></li>
  <li>Screen Height (768 or higher?): <%=heightResult %></li>
  <li>Screen Width (1024 or higher?): <%=widthResult %></li>
  <li>Connection Speed (30 kb or higher?): <%=speedResult %></li>
</ul>
</body>
</html>

View Entire Article

User Comments

Title: Browser Speed   
Name: Jason N. Gaylord
Date: 2006-07-06 1:58:17 PM
Comment:
Good review Steve. Quick question: So the speed coming out of the ConnectionSpeed property is in MBs and not KBs?

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2019 ASPAlliance.com  |  Page Processed at 2019-09-20 8:50:44 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search