Offline Messaging

From OpenSimulator

Revision as of 10:40, 7 December 2011 by World Sar (Talk | contribs)

Jump to: navigation, search

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

Through OpenSim.Wiredux 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

; 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


`uuid` varchar(36) NOT NULL,
`message` text NOT NULL,
 KEY `uuid` (`uuid`)


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=\"\" xmlns:xsd=\"\">"; 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
About This Wiki