>
> function shoutcast() {
> var _sRandom = Math.random();
> send = $("#single").val();
>
> oba = "getAndSetMessages.php?action=setMessages&value=" + send +'&_r=' +
> _sRandom,
>
>
> $.ajax({
> type: 'GET',
> url: "getAndSetMessages.php?action=setMessages&value=" + send +'&_r=' +
> _sRandom,
> timeout: 2000,
> success: function(sonuc) {
> $('.sonuc').append(sonuc);
> } });
> return true;
>
> }
>
This is Js function to send data.
<?
>
> include "memcache.php";
> $room = "roomName";
> $username = "Username";
> if($_GET['action'] == "getMessages") {
> $data = getCache($room);
> // var_dump($data);
>
> if($data !== false) {
> if($data[2] == false) {
> echo "$data[0]: $data[1]<br /> <br />";
> $data[2] = true;
> sleep(1);
> $memcache->delete($room);
>
> }
> }
>
> }
> else if($_GET['action'] == "setMessages") {
>
> $data = array($username,$_GET['value'],false);
> setCache($room,$data);
>
> }
> ?>
>
and this is set and get message.
What is the differance between 1 requrest per second and while loop ?
My problem is that, after some time ( 10 minutes ), chat.php doesn't work
anymore.
Also some messages doesn't go everyone.
On Tue, Jan 4, 2011 at 9:12 PM, Husseyn Alaouieh <[email protected]>wrote:
> Hi, i´m doing the same, but in asp.net.
>
> instead of send requests to server, use a while(true) loop to keep sending
> info for the client.
>
> if the interval between the messages is larger, back to the js getmessage.
>
> now, to your question:
>
> how are you selecting the data?
>
> 2011/1/4 - - <[email protected]>
>
> hello,
>> I'm trying to write a chat server with memcached. I decided to use
>> memcache because of
>>
>> 1. Faster than using HDD ( Database )
>> 2. Cheaper than using HDD ( Database )
>> 3. No need to save history
>>
>> I want to take information from you about how much is it logical.
>>
>> I'm using php and javascript
>>
>> chat.php
>>
>> There is a two JS function.
>> getmessage: every one second making a request to getmessage.php
>> setmessage: sending input valutes to setmessage.php
>>
>> getmessage.php
>> getCache($room,$data); ( $data is array hold username and text )
>> remove($room)
>>
>> setmessage.php
>> setCache($room,$data)
>>
>>
>> But it's not working as i want. When there are 2 or more users, message
>> doesn't go everyone.
>>
>> I used lock's but it didn't work.
>>
>> Is there any example, that i can take a look ?
>>
>> Is it logical to write a chat with memcached ?
>>
>> Thank you
>
>
>