AS3 + PHP + MySQL: ev yapımı online sohbet her zaman reaktif değil

0 Cevap php

Ben gönderir ve bir MySQL veritabanı ile iletişim kuran bir PHP komut dosyasından veri alır Flash (AS3) istemcisi ile çevrimiçi sohbet sistemi bir tür kodlu.

O occasionally, my client doesn't get one of the new chat lines, doğru veritabanında kayıtlı olsa bile gerçeği dışında, iyi çalışıyor.

Here is the basic logic behind it : every user has an entry in the database, and each of those entries has a lastChatCheck BigInt(16) variable. When a user types and sends a chat line, the client sends it to a PHP script, where it is stored in the database, along with the date it was stored at (it is also a BigInt(16) ). The flash client checks every 250 milliseconds through a getter PHP script for every chat line where (line's date>user's lastChatCheck), then sets the user's lastChatCheck to the last retrieved line's date. (Please tell me if this is confusing or poorly explained.)

Ben göndermek her şeyi doğru veritabanında saklanan alır gibi send yeni bir satır yazdı kod, doğru olumlu.

The (simplified) PHP code for getting the chat lines is like so :


$result=mysql_query('SELECT lastChatCheck FROM players WHERE id='.$id);
while ($row=mysql_fetch_array($result))
{
$lastChatCheck=$row['lastChatCheck'];
}

$output='';

$chatDate=0;

$result=mysql_query('SELECT * FROM chat WHERE date>'.$lastChatCheck);
while ($row=mysql_fetch_array($result))
{
$chatSayer=$row['sayer'];
$chatText=$row['text'];
$chatDate=$row['date'];
$result2=mysql_query('SELECT name FROM players WHERE id='.$chatSayer);
while ($row2=mysql_fetch_array($result2))
{
$output.=$row2['name'].' : '.$row['text'].'<br>';
//(in reality, $output is formatted as an XML object)
}

}


if ($chatDate!=0) mysql_query('UPDATE players SET lastChatCheck='.$chatDate.' WHERE id='.$id);

Bu son sohbet hatları bazı atlamak neden hiçbir mantıklı nedeni var mı? Ben bunu düzeltmek için herhangi bir yolu var mı?

0 Cevap