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>