Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

broadcast a message on a borswer

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi,

I have a tough question and can't be sloved. Please help!
I am helping my professor to write a PHP experiment game. It is playing on the browser. It is a Psychology experiment and data is stored on Oracle database. Here is the question: How can I broadcast a message to other players when one user has make his/her selection? It is like displaying a popup message to other when user A has make his/her choice!

Thanks for your advice and help in advance!

Sheeta
 
Sorry to spoil your fun, but this requires server push techniques.

Netscape is the only browser that supports server push (IE has never and probably will not support it), and even then, it is a real pain.

In any case, to create a server push, you have to pass headers in the fashion of the following example:



<?
//Insert server push script like an image in html file.
// i.e. <IMG SRC=&quot;campush.php3&quot;>


/*--------------------------*/

// filelocation of the webcam image
$filename= &quot;cam.jpg&quot;;

// how many time between push
// for unbuffered output set to 1.
$pause = &quot;10&quot;;

// how many time to pass to passthru function , don't set this to high for server usage
$PASSES = 20;

/*--------------------------*/
for ($j=0;$j<=$PASSES;$j++) {
$img[count($img)] = $filename;
}
/*--------------------------*/


/*--------------------------*/
/* Plot the Currrent Data Block of the image */
/*--------------------------*/
function plot_cam() {
global $filename,$img,$pause;
$k = 0;
$cstr = time(); // random string
Header(&quot;Content-type: multipart/x-mixed-replace;boundary=$cstr&quot;);
while ($img[$k]==$filename) {
print(&quot;\n--$cstr\n\n&quot;);
Header(&quot;Content-type: text/plain&quot;);
$cam = fopen($filename,&quot;r&quot;);
fpassthru($cam);
fclose($cam);
if ($pause) { sleep($pause);} // time between reload, usefull for server usage
$k++;
if ($k==count($img)) {
echo(&quot;\n--$cstr--\n&quot;);
}
}
}


/* Get the name the browser calls itself and what version */
$Browser_Name = strtok($HTTP_USER_AGENT, &quot;/&quot;);
$Browser_Version = strtok(&quot; &quot;);
/* MSIE lies about its name */
if(ereg(&quot;MSIE&quot;, $HTTP_USER_AGENT)) {
$Browser_Name = &quot;MSIE&quot;;
$Browser_Version = strtok(&quot;MSIE&quot;);
$Browser_Version = strtok(&quot; &quot;);
$Browser_Version = strtok(&quot;;&quot;);
}
/* Opera isn't completely honest, either ... */
/* Modificaton by Chris Mospaw <mospaw@polk-county.com> */
if(ereg(&quot;Opera&quot;, $HTTP_USER_AGENT)) {
$Browser_Name = &quot;Opera&quot;;
$Browser_Version = strtok(&quot;Opera&quot;);
$Browser_Version = strtok(&quot;/&quot;);
$Browser_Version = strtok(&quot;;&quot;);
}
/* try to figure out what platform, windows or mac */
$Browser_Platform = &quot;unknown&quot;;
if(ereg(&quot;Windows&quot;,$HTTP_USER_AGENT)
|| ereg(&quot;WinNT&quot;,$HTTP_USER_AGENT)
|| ereg(&quot;Win95&quot;,$HTTP_USER_AGENT)) {
$Browser_Platform = &quot;Windows&quot;;
}
if(ereg(&quot;Mac&quot;, $HTTP_USER_AGENT)) {
$Browser_Platform = &quot;Macintosh&quot;;
}
if(ereg(&quot;X11&quot;, $HTTP_USER_AGENT)) {
$Browser_Platform = &quot;Unix&quot;;
}

if(($Browser_Platform == &quot;Windows&quot;)){
if($Browser_Name == &quot;Mozilla&quot;) {
if($Browser_Version >= 3.0) {
}
// SERVER PUSH WORK'S ONLY HERE :)
if($Browser_Version >= 4.0) { plot_cam(); }
}
}

elseif($Browser_Platform == &quot;Macintosh&quot;) {
if($Browser_Name == &quot;Mozilla&quot;) {
if($Browser_Version >= 3.0) {
}
// SERVER PUSH WORK'S ONLY HERE :)
if($Browser_Version >= 4.0) {plot_cam();}
}
}
elseif($Browser_Platform == &quot;Unix&quot;) {
if($Browser_Name == &quot;Mozilla&quot;) {
if($Browser_Version >= 3.0) {
}
// SERVER PUSH WORK'S ONLY HERE :)
if($Browser_Version >= 4.0) { plot_cam();}
}
}

exit;
?>


I hope this gives you some insight.

Chad.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top