Offline Messaging

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
(Through OpenSim.Wiredux module)
(SQL file to load)
Line 33: Line 33:
 
P.D: The MuteListModule and URL must be uncommented in order for the offline module to work, even if there is no mute.php file in the web folder.
 
P.D: The MuteListModule and URL must be uncommented in order for the offline module to work, even if there is no mute.php file in the web folder.
  
=== SQL file to load ===
+
=== SQL file to load (Offline_IM.txt)===
 
<source lang=text>
 
<source lang=text>
  
Line 41: Line 41:
 
   KEY `uuid` (`uuid`)
 
   KEY `uuid` (`uuid`)
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
 +
 
</source >
 
</source >
  

Revision as of 09:49, 7 December 2011


Offline messaging makes it possible to send IM's to people that are not online and saves the messages directly to a database.

Through PHP module

In the latest version offline module is already ready to be used

  • Install the Offline_IM.sql file on your database

You need to enable the Offline Messaging Module in your Opensim.ini file.
You need to uploadt the offline.php to your web server(xampp).

Changes in the OpenSim.ini file

[Messaging]
; Control which region module is used for instant messaging.
; Default is InstantMessageModule (this is the name of the core IM module as well as the setting)
InstantMessageModule = InstantMessageModule
; MessageTransferModule = MessageTransferModule
OfflineMessageModule = OfflineMessageModule
OfflineMessageURL = http://yourserver/offline.php
MuteListModule = MuteListModule
MuteListURL = http://yourserver/mute.php
ForwardOfflineGroupMessages = true

When you did it right, reboot your region and try to send a message to an offline person. Check the database to see that it has written a record.

Next time that person logs in, he will get the message and the database will be updated

P.D: The MuteListModule and URL must be uncommented in order for the offline module to work, even if there is no mute.php file in the web folder.

SQL file to load (Offline_IM.txt)

CREATE TABLE IF NOT EXISTS `Offline_IM` (
 `uuid` varchar(36) NOT NULL,
 `message` text NOT NULL,
  KEY `uuid` (`uuid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

PHP for web server (offline.php)

<?php
$dbName = "comunity";
$dbHost = "localhost";
$dbUser = "root";
$dbPassword ="";
 
define("C_DB_TYPE","mysql");
define("C_DB_HOST",$dbHost);
define("C_DB_NAME",$dbName);
define("C_DB_USER",$dbUser);
define("C_DB_PASS",$dbPassword);
define("C_OFFLINE_IM_TBL", "Offline_IM");
include("mysql.php");
$DbLink = new DB;
$method = $_SERVER["PATH_INFO"];
if ($method == "/SaveMessage/")
{
$msg = $HTTP_RAW_POST_DATA;
$start = strpos($msg, "?>");
if ($start != -1)
{
$start+=2;
$msg = substr($msg, $start);
$parts = split("[<>]", $msg);
$to_agent = $parts[12];
$DbLink->query("insert into ".C_OFFLINE_IM_TBL." (uuid, message) values ('" .
mysql_escape_string($to_agent) . "', '" .
mysql_escape_string($msg) . "')");
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?><boolean>true</boolean>";
}
else
{
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?><boolean>false</boolean>";
}
exit;
}
if ($method == "/RetrieveMessages/")
{
$parms = $HTTP_RAW_POST_DATA;
$parts = split("[<>]", $parms);
$agent_id = $parts[6];
$DbLink->query("select message from ".C_OFFLINE_IM_TBL." where uuid='" .
mysql_escape_string($agent_id) . "'");
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?><ArrayOfGridInstantMessage xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">";
while(list($message) = $DbLink->next_record())
{
echo $message;
}
echo "</ArrayOfGridInstantMessage>";
$DbLink->query("delete from ".C_OFFLINE_IM_TBL." where uuid='" .
mysql_escape_string($agent_id) . "'");
exit;
}
?>
Personal tools
General
About This Wiki