<?php
session_start();
/*
Set rfirst user to default room
*/
require_once 'chatter_object.php';
// Also you can use memento::get($key) to get objects From Cache ;
// And New memento($object,"name",array("cacheparametrs"));
$chatBuilder= new chatdirector(
//BUILD DEFAULT USER AND CREATE FIRST USER I use memcahe for storing chatting
new room_builder("default","default",20),
new user_builder("demos", "pash", "hoho"),
array('cache'=>'memcache','memcache'=>array(array('host'=>"localhost",'port'=>11211)))
);
// Build Chat
$chatObj = $chatBuilder->chat() ;
if (isset($_GET["destroy"])) {
$chatBuilder->destroy();
die("CLEAR");
}
// GET USER AND SET ROOM FOR CHATTING
$user=$chatObj->getuser($_SESSION["current_chat"] );
$user->setRoom($chatObj->getroom("default"));
//print_r($chatObj->getuser($_SESSION["current_chat"] ));
// No comments //
if(isset($_POST["record"])) {
$user->set_reply($_POST["record"]);
}
if(isset($_GET["clearall"])) {
$user->set_reply($_POST["record"]);
}
/// SAVE CURRENT STATE OF CHAT
$chatBuilder->save();
?>
<html>
<head>
<title> Chat_class example FIRST USER </title>
</head>
<body>
<h3> Note You will need one ofthe PHP cache system(APC xCache, memcahce) installed on your server </h3>
<strong> Room Description <?=$chatObj->getroom("default")->description;?> </strong>
<form action="<?=$_SERVER['PHP_SELF']?>" method="POST">
<textarea name="main" style="width:400px;height:300px;">
<?
foreach($chatObj->getroom("default")->replys as $user=>$reply) {
print($user." => ".$reply. "\n");
}
?>
</textarea> <br/>
<input type="text" name="record" style="width:400px;"/> <input type="submit" value="Send"/>
</form>
</body>
</html>