mirror of
https://github.com/opensim/opensim.git
synced 2026-08-07 09:45:47 +08:00
* Optimized usings
* Shortened type references * Removed redundant 'this' qualifier
This commit is contained in:
@@ -26,11 +26,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
using OpenSim.Framework.Interfaces;
|
||||
using Nini.Config;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
using OpenSim.Region.Environment.Scenes;
|
||||
using OpenSim.Framework;
|
||||
using Nini.Config;
|
||||
|
||||
namespace OpenSim.Region.Environment.Modules
|
||||
{
|
||||
@@ -70,4 +69,4 @@ namespace OpenSim.Region.Environment.Modules
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using libsecondlife;
|
||||
using Nini.Config;
|
||||
using OpenSim.Framework;
|
||||
@@ -11,7 +8,8 @@ namespace OpenSim.Region.Environment.Modules
|
||||
{
|
||||
public class AvatarFactoryModule : IAvatarFactory
|
||||
{
|
||||
public bool TryGetIntialAvatarAppearance(LLUUID avatarId, out AvatarWearable[] wearables, out byte[] visualParams)
|
||||
public bool TryGetIntialAvatarAppearance(LLUUID avatarId, out AvatarWearable[] wearables,
|
||||
out byte[] visualParams)
|
||||
{
|
||||
GetDefaultAvatarAppearance(out wearables, out visualParams);
|
||||
return true;
|
||||
@@ -51,7 +49,4 @@ namespace OpenSim.Region.Environment.Modules
|
||||
wearables = AvatarWearable.DefaultWearables;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -27,11 +27,10 @@
|
||||
*/
|
||||
|
||||
using libsecondlife;
|
||||
using OpenSim.Framework.Interfaces;
|
||||
using Nini.Config;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
using OpenSim.Region.Environment.Scenes;
|
||||
using OpenSim.Framework;
|
||||
using Nini.Config;
|
||||
|
||||
namespace OpenSim.Region.Environment.Modules
|
||||
{
|
||||
@@ -92,4 +91,4 @@ namespace OpenSim.Region.Environment.Modules
|
||||
partner);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,13 +27,13 @@
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using libsecondlife;
|
||||
using OpenSim.Framework.Interfaces;
|
||||
using Nini.Config;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
@@ -54,18 +54,22 @@ namespace OpenSim.Region.Environment.Modules
|
||||
|
||||
public ChatModule()
|
||||
{
|
||||
m_log = OpenSim.Framework.Console.MainLog.Instance;
|
||||
m_log = MainLog.Instance;
|
||||
}
|
||||
|
||||
public void Initialise(Scene scene, Nini.Config.IConfigSource config)
|
||||
public void Initialise(Scene scene, IConfigSource config)
|
||||
{
|
||||
// wrap this in a try block so that defaults will work if
|
||||
// the config file doesn't specify otherwise.
|
||||
try {
|
||||
m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance);
|
||||
try
|
||||
{
|
||||
m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance);
|
||||
m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance);
|
||||
m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance);
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
if (!m_scenes.Contains(scene))
|
||||
{
|
||||
@@ -73,20 +77,20 @@ namespace OpenSim.Region.Environment.Modules
|
||||
scene.EventManager.OnNewClient += NewClient;
|
||||
scene.RegisterModuleInterface<ISimChat>(this);
|
||||
}
|
||||
|
||||
|
||||
// setup IRC Relay
|
||||
m_irc = new IRCChatModule(config);
|
||||
}
|
||||
|
||||
public void PostInitialise()
|
||||
{
|
||||
|
||||
if (m_irc.Enabled) {
|
||||
if (m_irc.Enabled)
|
||||
{
|
||||
m_irc.Connect(m_scenes);
|
||||
}
|
||||
}
|
||||
|
||||
public void Close()
|
||||
public void Close()
|
||||
{
|
||||
m_irc.Close();
|
||||
}
|
||||
@@ -111,7 +115,7 @@ namespace OpenSim.Region.Environment.Modules
|
||||
ScenePresence avatar = null;
|
||||
|
||||
//TODO: Move ForEachScenePresence and others into IScene.
|
||||
Scene scene = (Scene)e.Scene;
|
||||
Scene scene = (Scene) e.Scene;
|
||||
|
||||
//TODO: Remove the need for this check
|
||||
if (scene == null)
|
||||
@@ -119,10 +123,12 @@ namespace OpenSim.Region.Environment.Modules
|
||||
|
||||
// Filled in since it's easier than rewriting right now.
|
||||
LLVector3 fromPos = e.Position;
|
||||
LLVector3 fromRegionPos = e.Position + new LLVector3(e.Scene.RegionInfo.RegionLocX * 256, e.Scene.RegionInfo.RegionLocY * 256, 0);
|
||||
LLVector3 fromRegionPos = e.Position +
|
||||
new LLVector3(e.Scene.RegionInfo.RegionLocX*256, e.Scene.RegionInfo.RegionLocY*256,
|
||||
0);
|
||||
string fromName = e.From;
|
||||
string message = e.Message;
|
||||
byte type = (byte)e.Type;
|
||||
byte type = (byte) e.Type;
|
||||
LLUUID fromAgentID = LLUUID.Zero;
|
||||
|
||||
if (e.Sender != null)
|
||||
@@ -133,7 +139,8 @@ namespace OpenSim.Region.Environment.Modules
|
||||
if (avatar != null)
|
||||
{
|
||||
fromPos = avatar.AbsolutePosition;
|
||||
fromRegionPos = fromPos + new LLVector3(e.Scene.RegionInfo.RegionLocX * 256, e.Scene.RegionInfo.RegionLocY * 256, 0);
|
||||
fromRegionPos = fromPos +
|
||||
new LLVector3(e.Scene.RegionInfo.RegionLocX*256, e.Scene.RegionInfo.RegionLocY*256, 0);
|
||||
fromName = avatar.Firstname + " " + avatar.Lastname;
|
||||
fromAgentID = e.Sender.AgentId;
|
||||
avatar = null;
|
||||
@@ -159,75 +166,84 @@ namespace OpenSim.Region.Environment.Modules
|
||||
break;
|
||||
}
|
||||
|
||||
m_log.Verbose("CHAT", fromName + " (" + e.Channel + " @ " + scene.RegionInfo.RegionName + ") " + typeName + ": " + e.Message);
|
||||
m_log.Verbose("CHAT",
|
||||
fromName + " (" + e.Channel + " @ " + scene.RegionInfo.RegionName + ") " + typeName + ": " +
|
||||
e.Message);
|
||||
|
||||
if (m_irc.Connected)
|
||||
{
|
||||
m_irc.PrivMsg(fromName, scene.RegionInfo.RegionName, e.Message);
|
||||
}
|
||||
|
||||
if (e.Channel == 0)
|
||||
{
|
||||
foreach (Scene m_scene in m_scenes)
|
||||
{
|
||||
m_scene.ForEachScenePresence(delegate(ScenePresence presence)
|
||||
{
|
||||
int dis = -100000;
|
||||
if (m_irc.Connected)
|
||||
{
|
||||
m_irc.PrivMsg(fromName, scene.RegionInfo.RegionName, e.Message);
|
||||
}
|
||||
|
||||
LLVector3 avatarRegionPos = presence.AbsolutePosition + new LLVector3(scene.RegionInfo.RegionLocX * 256, scene.RegionInfo.RegionLocY * 256, 0);
|
||||
dis = Math.Abs((int)avatarRegionPos.GetDistanceTo(fromRegionPos));
|
||||
if (e.Channel == 0)
|
||||
{
|
||||
foreach (Scene m_scene in m_scenes)
|
||||
{
|
||||
m_scene.ForEachScenePresence(delegate(ScenePresence presence)
|
||||
{
|
||||
int dis = -100000;
|
||||
|
||||
switch (e.Type)
|
||||
{
|
||||
case ChatTypeEnum.Whisper:
|
||||
if (dis < m_whisperdistance)
|
||||
{
|
||||
//should change so the message is sent through the avatar rather than direct to the ClientView
|
||||
presence.ControllingClient.SendChatMessage(message,
|
||||
type,
|
||||
fromPos,
|
||||
fromName,
|
||||
fromAgentID);
|
||||
}
|
||||
break;
|
||||
case ChatTypeEnum.Say:
|
||||
if (dis < m_saydistance)
|
||||
{
|
||||
//Console.WriteLine("sending chat");
|
||||
presence.ControllingClient.SendChatMessage(message,
|
||||
type,
|
||||
fromPos,
|
||||
fromName,
|
||||
fromAgentID);
|
||||
}
|
||||
break;
|
||||
case ChatTypeEnum.Shout:
|
||||
if (dis < m_shoutdistance)
|
||||
{
|
||||
presence.ControllingClient.SendChatMessage(message,
|
||||
type,
|
||||
fromPos,
|
||||
fromName,
|
||||
fromAgentID);
|
||||
}
|
||||
break;
|
||||
|
||||
case ChatTypeEnum.Broadcast:
|
||||
presence.ControllingClient.SendChatMessage(message, type,
|
||||
fromPos,
|
||||
fromName,
|
||||
fromAgentID);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
LLVector3 avatarRegionPos = presence.AbsolutePosition +
|
||||
new LLVector3(
|
||||
scene.RegionInfo.RegionLocX*256,
|
||||
scene.RegionInfo.RegionLocY*256,
|
||||
0);
|
||||
dis =
|
||||
Math.Abs((int) avatarRegionPos.GetDistanceTo(fromRegionPos));
|
||||
|
||||
switch (e.Type)
|
||||
{
|
||||
case ChatTypeEnum.Whisper:
|
||||
if (dis < m_whisperdistance)
|
||||
{
|
||||
//should change so the message is sent through the avatar rather than direct to the ClientView
|
||||
presence.ControllingClient.SendChatMessage(message,
|
||||
type,
|
||||
fromPos,
|
||||
fromName,
|
||||
fromAgentID);
|
||||
}
|
||||
break;
|
||||
case ChatTypeEnum.Say:
|
||||
if (dis < m_saydistance)
|
||||
{
|
||||
//Console.WriteLine("sending chat");
|
||||
presence.ControllingClient.SendChatMessage(message,
|
||||
type,
|
||||
fromPos,
|
||||
fromName,
|
||||
fromAgentID);
|
||||
}
|
||||
break;
|
||||
case ChatTypeEnum.Shout:
|
||||
if (dis < m_shoutdistance)
|
||||
{
|
||||
presence.ControllingClient.SendChatMessage(message,
|
||||
type,
|
||||
fromPos,
|
||||
fromName,
|
||||
fromAgentID);
|
||||
}
|
||||
break;
|
||||
|
||||
case ChatTypeEnum.Broadcast:
|
||||
presence.ControllingClient.SendChatMessage(message,
|
||||
type,
|
||||
fromPos,
|
||||
fromName,
|
||||
fromAgentID);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class IRCChatModule {
|
||||
internal class IRCChatModule
|
||||
{
|
||||
private string m_server = null;
|
||||
private int m_port = 6668;
|
||||
private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot";
|
||||
@@ -238,7 +254,7 @@ namespace OpenSim.Region.Environment.Modules
|
||||
private TcpClient m_tcp;
|
||||
private StreamWriter m_writer;
|
||||
private StreamReader m_reader;
|
||||
|
||||
|
||||
private Thread pingSender;
|
||||
private Thread listener;
|
||||
|
||||
@@ -248,29 +264,36 @@ namespace OpenSim.Region.Environment.Modules
|
||||
private List<Scene> m_scenes = null;
|
||||
private LogBase m_log;
|
||||
|
||||
public IRCChatModule(Nini.Config.IConfigSource config) {
|
||||
public IRCChatModule(IConfigSource config)
|
||||
{
|
||||
m_nick = "OSimBot" + Util.RandomClass.Next(1, 99);
|
||||
m_tcp = null;
|
||||
m_writer = null;
|
||||
m_reader = null;
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
m_server = config.Configs["IRC"].GetString("server");
|
||||
m_nick = config.Configs["IRC"].GetString("nick");
|
||||
m_channel = config.Configs["IRC"].GetString("channel");
|
||||
m_port = config.Configs["IRC"].GetInt("port", m_port);
|
||||
m_user = config.Configs["IRC"].GetString("username", m_user);
|
||||
if (m_server != null && m_nick != null && m_channel != null) {
|
||||
if (m_server != null && m_nick != null && m_channel != null)
|
||||
{
|
||||
m_enabled = true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine("No IRC config information, skipping IRC bridge configuration");
|
||||
}
|
||||
m_log = OpenSim.Framework.Console.MainLog.Instance;
|
||||
m_log = MainLog.Instance;
|
||||
}
|
||||
|
||||
public bool Connect(List<Scene> scenes) {
|
||||
try {
|
||||
public bool Connect(List<Scene> scenes)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_scenes = scenes;
|
||||
|
||||
m_tcp = new TcpClient(m_server, m_port);
|
||||
@@ -279,13 +302,13 @@ namespace OpenSim.Region.Environment.Modules
|
||||
m_log.Verbose("IRC", "Connected to " + m_server);
|
||||
m_reader = new StreamReader(m_stream);
|
||||
m_writer = new StreamWriter(m_stream);
|
||||
|
||||
pingSender = new Thread(new ThreadStart(this.PingRun));
|
||||
|
||||
pingSender = new Thread(new ThreadStart(PingRun));
|
||||
pingSender.Start();
|
||||
|
||||
listener = new Thread(new ThreadStart(this.ListenerRun));
|
||||
|
||||
listener = new Thread(new ThreadStart(ListenerRun));
|
||||
listener.Start();
|
||||
|
||||
|
||||
m_writer.WriteLine(m_user);
|
||||
m_writer.Flush();
|
||||
m_writer.WriteLine("NICK " + m_nick);
|
||||
@@ -294,50 +317,61 @@ namespace OpenSim.Region.Environment.Modules
|
||||
m_writer.Flush();
|
||||
m_log.Verbose("IRC", "Connection fully established");
|
||||
m_connected = true;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
}
|
||||
return m_connected;
|
||||
}
|
||||
|
||||
public bool Enabled
|
||||
public bool Enabled
|
||||
{
|
||||
get { return m_enabled; }
|
||||
}
|
||||
|
||||
|
||||
public bool Connected
|
||||
{
|
||||
get { return m_connected; }
|
||||
}
|
||||
|
||||
public void PrivMsg(string from, string region, string msg) {
|
||||
try {
|
||||
public void PrivMsg(string from, string region, string msg)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_writer.WriteLine("PRIVMSG {0} :<{1} in {2}>: {3}", m_channel, from, region, msg);
|
||||
m_writer.Flush();
|
||||
} catch (IOException) {
|
||||
m_log.Error("IRC","Disconnected from IRC server.");
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
m_log.Error("IRC", "Disconnected from IRC server.");
|
||||
listener.Abort();
|
||||
pingSender.Abort();
|
||||
m_connected = false;
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<string, string> ExtractMsg(string input) {
|
||||
private Dictionary<string, string> ExtractMsg(string input)
|
||||
{
|
||||
Dictionary<string, string> result = null;
|
||||
string regex = @":(?<nick>\w*)!~(?<user>\S*) PRIVMSG (?<channel>\S+) :(?<msg>.*)";
|
||||
Regex RE = new Regex(regex, RegexOptions.Multiline);
|
||||
MatchCollection matches = RE.Matches(input);
|
||||
// Get some direct matches $1 $4 is a
|
||||
if ((matches.Count == 1) && (matches[0].Groups.Count == 5)) {
|
||||
if ((matches.Count == 1) && (matches[0].Groups.Count == 5))
|
||||
{
|
||||
result = new Dictionary<string, string>();
|
||||
result.Add("nick", matches[0].Groups[1].Value);
|
||||
result.Add("user", matches[0].Groups[2].Value);
|
||||
result.Add("channel", matches[0].Groups[3].Value);
|
||||
result.Add("msg", matches[0].Groups[4].Value);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.Verbose("IRC", "Number of matches: " + matches.Count);
|
||||
if (matches.Count > 0) {
|
||||
m_log.Verbose("IRC", "Number of groups: " + matches[0].Groups.Count);
|
||||
if (matches.Count > 0)
|
||||
{
|
||||
m_log.Verbose("IRC", "Number of groups: " + matches[0].Groups.Count);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -365,19 +399,20 @@ namespace OpenSim.Region.Environment.Modules
|
||||
if (inputLine.Contains(m_channel))
|
||||
{
|
||||
Dictionary<string, string> data = ExtractMsg(inputLine);
|
||||
if (data != null )
|
||||
if (data != null)
|
||||
{
|
||||
foreach (Scene m_scene in m_scenes)
|
||||
{
|
||||
m_scene.ForEachScenePresence(delegate(ScenePresence avatar)
|
||||
{
|
||||
if (!avatar.IsChildAgent)
|
||||
{
|
||||
avatar.ControllingClient.SendChatMessage(
|
||||
Helpers.StringToField(data["msg"]), 255, pos, data["nick"],
|
||||
LLUUID.Zero);
|
||||
}
|
||||
});
|
||||
if (!avatar.IsChildAgent)
|
||||
{
|
||||
avatar.ControllingClient.SendChatMessage(
|
||||
Helpers.StringToField(data["msg"]), 255,
|
||||
pos, data["nick"],
|
||||
LLUUID.Zero);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -387,7 +422,8 @@ namespace OpenSim.Region.Environment.Modules
|
||||
}
|
||||
|
||||
|
||||
public void Close() {
|
||||
public void Close()
|
||||
{
|
||||
listener.Abort();
|
||||
pingSender.Abort();
|
||||
m_writer.Close();
|
||||
@@ -395,4 +431,4 @@ namespace OpenSim.Region.Environment.Modules
|
||||
m_tcp.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,10 +29,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using libsecondlife;
|
||||
using Nini.Config;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
using OpenSim.Region.Environment.Scenes;
|
||||
using Nini.Config;
|
||||
|
||||
namespace OpenSim.Region.Environment.Modules
|
||||
{
|
||||
@@ -99,7 +99,7 @@ namespace OpenSim.Region.Environment.Modules
|
||||
if (RenderPlugins.ContainsKey(contentType))
|
||||
{
|
||||
//Console.WriteLine("dynamic texture being created: " + url + " of type " + contentType);
|
||||
|
||||
|
||||
DynamicTextureUpdater updater = new DynamicTextureUpdater();
|
||||
updater.SimUUID = simID;
|
||||
updater.PrimID = primID;
|
||||
@@ -187,4 +187,4 @@ namespace OpenSim.Region.Environment.Modules
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,4 +31,4 @@ namespace OpenSim.Region.Environment.Modules
|
||||
internal class EmailModule
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,9 +26,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
using Nini.Config;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
using OpenSim.Region.Environment.Scenes;
|
||||
using Nini.Config;
|
||||
|
||||
namespace OpenSim.Region.Environment.Modules
|
||||
{
|
||||
@@ -59,4 +59,4 @@ namespace OpenSim.Region.Environment.Modules
|
||||
get { return false; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,9 +26,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
using Nini.Config;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
using OpenSim.Region.Environment.Scenes;
|
||||
using Nini.Config;
|
||||
|
||||
namespace OpenSim.Region.Environment.Modules
|
||||
{
|
||||
@@ -59,4 +59,4 @@ namespace OpenSim.Region.Environment.Modules
|
||||
get { return false; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,11 +27,12 @@
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using libsecondlife;
|
||||
using Nini.Config;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
using OpenSim.Region.Environment.Scenes;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Framework;
|
||||
using Nini.Config;
|
||||
|
||||
namespace OpenSim.Region.Environment.Modules
|
||||
{
|
||||
@@ -42,7 +43,7 @@ namespace OpenSim.Region.Environment.Modules
|
||||
|
||||
public InstantMessageModule()
|
||||
{
|
||||
m_log = OpenSim.Framework.Console.MainLog.Instance;
|
||||
m_log = MainLog.Instance;
|
||||
}
|
||||
|
||||
public void Initialise(Scene scene, IConfigSource config)
|
||||
@@ -50,33 +51,34 @@ namespace OpenSim.Region.Environment.Modules
|
||||
if (!m_scenes.Contains(scene))
|
||||
{
|
||||
m_scenes.Add(scene);
|
||||
scene.EventManager.OnNewClient += OnNewClient;
|
||||
scene.EventManager.OnNewClient += OnNewClient;
|
||||
}
|
||||
}
|
||||
|
||||
void OnNewClient(OpenSim.Framework.IClientAPI client)
|
||||
private void OnNewClient(IClientAPI client)
|
||||
{
|
||||
client.OnInstantMessage += OnInstantMessage;
|
||||
}
|
||||
|
||||
void OnInstantMessage(libsecondlife.LLUUID fromAgentID,
|
||||
libsecondlife.LLUUID fromAgentSession, libsecondlife.LLUUID toAgentID,
|
||||
libsecondlife.LLUUID imSessionID, uint timestamp, string fromAgentName,
|
||||
string message, byte dialog)
|
||||
private void OnInstantMessage(LLUUID fromAgentID,
|
||||
LLUUID fromAgentSession, LLUUID toAgentID,
|
||||
LLUUID imSessionID, uint timestamp, string fromAgentName,
|
||||
string message, byte dialog)
|
||||
{
|
||||
// TODO: Remove after debugging. Privacy implications.
|
||||
m_log.Verbose("IM",fromAgentName + ": " + message);
|
||||
m_log.Verbose("IM", fromAgentName + ": " + message);
|
||||
|
||||
foreach (Scene m_scene in m_scenes)
|
||||
{
|
||||
if (m_scene.Entities.ContainsKey(toAgentID) && m_scene.Entities[toAgentID] is ScenePresence)
|
||||
{
|
||||
// Local Message
|
||||
ScenePresence user = (ScenePresence)m_scene.Entities[toAgentID];
|
||||
ScenePresence user = (ScenePresence) m_scene.Entities[toAgentID];
|
||||
if (!user.IsChildAgent)
|
||||
{
|
||||
user.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message,
|
||||
toAgentID, imSessionID, fromAgentName, dialog, timestamp);
|
||||
toAgentID, imSessionID, fromAgentName, dialog,
|
||||
timestamp);
|
||||
}
|
||||
// Message sent
|
||||
return;
|
||||
@@ -104,4 +106,4 @@ namespace OpenSim.Region.Environment.Modules
|
||||
get { return true; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,9 +26,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
using Nini.Config;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
using OpenSim.Region.Environment.Scenes;
|
||||
using Nini.Config;
|
||||
|
||||
namespace OpenSim.Region.Environment.Modules
|
||||
{
|
||||
@@ -59,4 +59,4 @@ namespace OpenSim.Region.Environment.Modules
|
||||
get { return false; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.IO;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using libsecondlife;
|
||||
using OpenJPEGNet;
|
||||
using OpenSim.Region.Environment.Scenes;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
using Nini.Config;
|
||||
using OpenJPEGNet;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
using OpenSim.Region.Environment.Scenes;
|
||||
|
||||
namespace OpenSim.Region.Environment.Modules
|
||||
{
|
||||
public class LoadImageURLModule : IRegionModule , IDynamicTextureRender
|
||||
public class LoadImageURLModule : IRegionModule, IDynamicTextureRender
|
||||
{
|
||||
private string m_name = "LoadImageURL";
|
||||
private IDynamicTextureManager m_textureManager;
|
||||
@@ -85,25 +83,25 @@ namespace OpenSim.Region.Environment.Modules
|
||||
private void MakeHttpRequest(string url, LLUUID requestID)
|
||||
{
|
||||
WebRequest request = HttpWebRequest.Create(url);
|
||||
RequestState state = new RequestState((HttpWebRequest)request, requestID);
|
||||
RequestState state = new RequestState((HttpWebRequest) request, requestID);
|
||||
IAsyncResult result = request.BeginGetResponse(new AsyncCallback(HttpRequestReturn), state);
|
||||
|
||||
TimeSpan t = (DateTime.UtcNow - new DateTime(1970, 1, 1));
|
||||
state.TimeOfRequest = (int)t.TotalSeconds;
|
||||
state.TimeOfRequest = (int) t.TotalSeconds;
|
||||
}
|
||||
|
||||
private void HttpRequestReturn(IAsyncResult result)
|
||||
{
|
||||
RequestState state = (RequestState)result.AsyncState;
|
||||
WebRequest request = (WebRequest)state.Request;
|
||||
HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(result);
|
||||
RequestState state = (RequestState) result.AsyncState;
|
||||
WebRequest request = (WebRequest) state.Request;
|
||||
HttpWebResponse response = (HttpWebResponse) request.EndGetResponse(result);
|
||||
if (response.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
Bitmap image = new Bitmap(response.GetResponseStream());
|
||||
Bitmap resize = new Bitmap(image, new Size(512, 512));
|
||||
byte[] imageJ2000 = OpenJPEG.EncodeFromImage(resize, true);
|
||||
Bitmap image = new Bitmap(response.GetResponseStream());
|
||||
Bitmap resize = new Bitmap(image, new Size(512, 512));
|
||||
byte[] imageJ2000 = OpenJPEG.EncodeFromImage(resize, true);
|
||||
|
||||
m_textureManager.ReturnData(state.RequestID, imageJ2000);
|
||||
m_textureManager.ReturnData(state.RequestID, imageJ2000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,6 +117,5 @@ namespace OpenSim.Region.Environment.Modules
|
||||
RequestID = requestID;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,4 +31,4 @@ namespace OpenSim.Region.Environment.Modules
|
||||
internal class ScriptsHttpRequests
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,4 +31,4 @@ namespace OpenSim.Region.Environment.Modules
|
||||
internal class TeleportModule
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,14 +27,12 @@
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using libsecondlife;
|
||||
using libsecondlife.Packets;
|
||||
using OpenSim.Framework.Interfaces;
|
||||
using Nini.Config;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
using OpenSim.Region.Environment.Scenes;
|
||||
using Nini.Config;
|
||||
|
||||
namespace OpenSim.Region.Environment.Modules
|
||||
{
|
||||
@@ -42,17 +40,19 @@ namespace OpenSim.Region.Environment.Modules
|
||||
{
|
||||
private Scene m_scene;
|
||||
private List<Scene> m_scenes = new List<Scene>();
|
||||
private Dictionary<LLUUID, Dictionary<LLUUID, AssetRequest>> ClientRequests = new Dictionary<LLUUID, Dictionary<LLUUID, AssetRequest>>();
|
||||
|
||||
private Dictionary<LLUUID, Dictionary<LLUUID, AssetRequest>> ClientRequests =
|
||||
new Dictionary<LLUUID, Dictionary<LLUUID, AssetRequest>>();
|
||||
|
||||
private BlockingQueue<TextureSender> QueueSenders = new BlockingQueue<TextureSender>();
|
||||
private Dictionary<LLUUID, List<LLUUID>> InProcess = new Dictionary<LLUUID, List<LLUUID>>();
|
||||
// private Thread m_thread;
|
||||
// private Thread m_thread;
|
||||
|
||||
public TextureDownloadModule()
|
||||
{
|
||||
// m_thread = new Thread(new ThreadStart(ProcessTextureSenders));
|
||||
// m_thread.IsBackground = true;
|
||||
// m_thread.Start();
|
||||
// m_thread = new Thread(new ThreadStart(ProcessTextureSenders));
|
||||
// m_thread.IsBackground = true;
|
||||
// m_thread.Start();
|
||||
}
|
||||
|
||||
public void Initialise(Scene scene, IConfigSource config)
|
||||
@@ -85,7 +85,7 @@ namespace OpenSim.Region.Environment.Modules
|
||||
|
||||
public void NewClient(IClientAPI client)
|
||||
{
|
||||
/* lock (ClientRequests)
|
||||
/* lock (ClientRequests)
|
||||
{
|
||||
if (!ClientRequests.ContainsKey(client.AgentId))
|
||||
{
|
||||
@@ -120,7 +120,7 @@ namespace OpenSim.Region.Environment.Modules
|
||||
|
||||
public void TextureRequest(Object sender, TextureRequestArgs e)
|
||||
{
|
||||
IClientAPI client = (IClientAPI)sender;
|
||||
IClientAPI client = (IClientAPI) sender;
|
||||
if (!ClientRequests[client.AgentId].ContainsKey(e.RequestedAssetID))
|
||||
{
|
||||
lock (ClientRequests)
|
||||
@@ -136,15 +136,15 @@ namespace OpenSim.Region.Environment.Modules
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
TextureSender sender = this.QueueSenders.Dequeue();
|
||||
TextureSender sender = QueueSenders.Dequeue();
|
||||
bool finished = sender.SendTexture();
|
||||
if (finished)
|
||||
{
|
||||
this.TextureSent(sender);
|
||||
TextureSent(sender);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.QueueSenders.Enqueue(sender);
|
||||
QueueSenders.Enqueue(sender);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -173,13 +173,13 @@ namespace OpenSim.Region.Environment.Modules
|
||||
|
||||
if (asset.Data.LongLength > 600)
|
||||
{
|
||||
NumPackets = 2 + (int)(asset.Data.Length - 601) / 1000;
|
||||
NumPackets = 2 + (int) (asset.Data.Length - 601)/1000;
|
||||
}
|
||||
else
|
||||
{
|
||||
NumPackets = 1;
|
||||
}
|
||||
|
||||
|
||||
PacketCounter = (int) req.PacketNumber;
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ namespace OpenSim.Region.Environment.Modules
|
||||
im.Header.Reliable = false;
|
||||
im.ImageID.Packets = 1;
|
||||
im.ImageID.ID = m_asset.FullID;
|
||||
im.ImageID.Size = (uint)m_asset.Data.Length;
|
||||
im.ImageID.Size = (uint) m_asset.Data.Length;
|
||||
im.ImageData.Data = m_asset.Data;
|
||||
im.ImageID.Codec = 2;
|
||||
req.RequestUser.OutPacket(im);
|
||||
@@ -215,9 +215,9 @@ namespace OpenSim.Region.Environment.Modules
|
||||
{
|
||||
ImageDataPacket im = new ImageDataPacket();
|
||||
im.Header.Reliable = false;
|
||||
im.ImageID.Packets = (ushort)(NumPackets);
|
||||
im.ImageID.Packets = (ushort) (NumPackets);
|
||||
im.ImageID.ID = m_asset.FullID;
|
||||
im.ImageID.Size = (uint)m_asset.Data.Length;
|
||||
im.ImageID.Size = (uint) m_asset.Data.Length;
|
||||
im.ImageData.Data = new byte[600];
|
||||
Array.Copy(m_asset.Data, 0, im.ImageData.Data, 0, 600);
|
||||
im.ImageID.Codec = 2;
|
||||
@@ -229,18 +229,16 @@ namespace OpenSim.Region.Environment.Modules
|
||||
{
|
||||
ImagePacketPacket im = new ImagePacketPacket();
|
||||
im.Header.Reliable = false;
|
||||
im.ImageID.Packet = (ushort)(PacketCounter);
|
||||
im.ImageID.Packet = (ushort) (PacketCounter);
|
||||
im.ImageID.ID = m_asset.FullID;
|
||||
int size = m_asset.Data.Length - 600 - (1000 * (PacketCounter - 1));
|
||||
int size = m_asset.Data.Length - 600 - (1000*(PacketCounter - 1));
|
||||
if (size > 1000) size = 1000;
|
||||
im.ImageData.Data = new byte[size];
|
||||
Array.Copy(m_asset.Data, 600 + (1000 * (PacketCounter - 1)), im.ImageData.Data, 0, size);
|
||||
Array.Copy(m_asset.Data, 600 + (1000*(PacketCounter - 1)), im.ImageData.Data, 0, size);
|
||||
req.RequestUser.OutPacket(im);
|
||||
PacketCounter++;
|
||||
PacketCounter++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class AssetRequest
|
||||
@@ -258,6 +256,5 @@ namespace OpenSim.Region.Environment.Modules
|
||||
PacketNumber = packetNumber;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,20 +27,12 @@
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Collections.Generic;
|
||||
using libsecondlife;
|
||||
using OpenSim.Framework.Interfaces;
|
||||
using Nini.Config;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
using OpenSim.Region.Environment.Scenes;
|
||||
using OpenSim.Framework.Servers;
|
||||
using Nwc.XmlRpc;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Nini.Config;
|
||||
|
||||
/*****************************************************
|
||||
*
|
||||
@@ -71,6 +63,7 @@ using Nini.Config;
|
||||
* thats the way it works.
|
||||
*
|
||||
* **************************************************/
|
||||
|
||||
namespace OpenSim.Region.Environment.Modules
|
||||
{
|
||||
public class WorldCommModule : IRegionModule, IWorldComm
|
||||
@@ -120,9 +113,9 @@ namespace OpenSim.Region.Environment.Modules
|
||||
private void DeliverClientMessage(Object sender, ChatFromViewerArgs e)
|
||||
{
|
||||
DeliverMessage(e.Sender.AgentId.ToString(),
|
||||
(int)e.Type, e.Channel,
|
||||
e.Sender.FirstName + " " + e.Sender.LastName,
|
||||
e.Message);
|
||||
(int) e.Type, e.Channel,
|
||||
e.Sender.FirstName + " " + e.Sender.LastName,
|
||||
e.Message);
|
||||
}
|
||||
|
||||
public int Listen(uint localID, LLUUID itemID, LLUUID hostID, int channel, string name, string id, string msg)
|
||||
@@ -132,11 +125,10 @@ namespace OpenSim.Region.Environment.Modules
|
||||
|
||||
public void ListenControl(int handle, int active)
|
||||
{
|
||||
if ( active == 1 )
|
||||
if (active == 1)
|
||||
m_listenerManager.Activate(handle);
|
||||
else if ( active == 0 )
|
||||
else if (active == 0)
|
||||
m_listenerManager.Dectivate(handle);
|
||||
|
||||
}
|
||||
|
||||
public void ListenRemove(int handle)
|
||||
@@ -151,7 +143,6 @@ namespace OpenSim.Region.Environment.Modules
|
||||
// nearby avatards, the SimChat function is used.
|
||||
public void DeliverMessage(string sourceItemID, int type, int channel, string name, string msg)
|
||||
{
|
||||
|
||||
SceneObjectPart source = null;
|
||||
ScenePresence avatar = null;
|
||||
|
||||
@@ -160,7 +151,7 @@ namespace OpenSim.Region.Environment.Modules
|
||||
{
|
||||
avatar = m_scene.GetScenePresence(new LLUUID(sourceItemID));
|
||||
}
|
||||
if( (avatar != null) || (source != null) )
|
||||
if ((avatar != null) || (source != null))
|
||||
{
|
||||
// Loop through the objects in the scene
|
||||
// If they are in proximity, then if they are
|
||||
@@ -169,12 +160,12 @@ namespace OpenSim.Region.Environment.Modules
|
||||
foreach (LLUUID eb in m_scene.Entities.Keys)
|
||||
{
|
||||
EntityBase sPart;
|
||||
|
||||
|
||||
m_scene.Entities.TryGetValue(eb, out sPart);
|
||||
|
||||
// Dont process if this message is from itself!
|
||||
if (eb.ToString().Equals(sourceItemID) ||
|
||||
sPart.UUID.ToString().Equals(sourceItemID) )
|
||||
sPart.UUID.ToString().Equals(sourceItemID))
|
||||
continue;
|
||||
|
||||
double dis = 0;
|
||||
@@ -192,12 +183,11 @@ namespace OpenSim.Region.Environment.Modules
|
||||
{
|
||||
ListenerInfo isListener = m_listenerManager.IsListenerMatch(
|
||||
sourceItemID, sPart.UUID, channel, name, msg
|
||||
);
|
||||
);
|
||||
if (isListener != null)
|
||||
{
|
||||
m_pending.Enqueue(isListener);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -207,12 +197,11 @@ namespace OpenSim.Region.Environment.Modules
|
||||
{
|
||||
ListenerInfo isListener = m_listenerManager.IsListenerMatch(
|
||||
sourceItemID, sPart.UUID, channel, name, msg
|
||||
);
|
||||
);
|
||||
if (isListener != null)
|
||||
{
|
||||
m_pending.Enqueue(isListener);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -221,22 +210,22 @@ namespace OpenSim.Region.Environment.Modules
|
||||
{
|
||||
ListenerInfo isListener = m_listenerManager.IsListenerMatch(
|
||||
sourceItemID, sPart.UUID, channel, name, msg
|
||||
);
|
||||
);
|
||||
if (isListener != null)
|
||||
{
|
||||
m_pending.Enqueue(isListener);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case 0xff: // Broadcast
|
||||
ListenerInfo isListen = m_listenerManager.IsListenerMatch(sourceItemID, eb, channel, name, msg);
|
||||
ListenerInfo isListen =
|
||||
m_listenerManager.IsListenerMatch(sourceItemID, eb, channel, name, msg);
|
||||
if (isListen != null)
|
||||
{
|
||||
ListenerInfo isListener = m_listenerManager.IsListenerMatch(
|
||||
sourceItemID, sPart.UUID, channel, name, msg
|
||||
);
|
||||
);
|
||||
if (isListener != null)
|
||||
{
|
||||
m_pending.Enqueue(isListener);
|
||||
@@ -244,10 +233,9 @@ namespace OpenSim.Region.Environment.Modules
|
||||
}
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public bool HasMessages()
|
||||
@@ -257,18 +245,15 @@ namespace OpenSim.Region.Environment.Modules
|
||||
|
||||
public ListenerInfo GetNextMessage()
|
||||
{
|
||||
|
||||
ListenerInfo li = null;
|
||||
|
||||
lock (CommListLock)
|
||||
{
|
||||
li = m_pending.Dequeue();
|
||||
li = m_pending.Dequeue();
|
||||
}
|
||||
|
||||
return li;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// hostID: the ID of the ScenePart
|
||||
@@ -285,20 +270,19 @@ namespace OpenSim.Region.Environment.Modules
|
||||
m_listeners = new Dictionary<int, ListenerInfo>();
|
||||
}
|
||||
|
||||
public int AddListener(uint localID, LLUUID itemID, LLUUID hostID, int channel, string name, string id, string msg)
|
||||
public int AddListener(uint localID, LLUUID itemID, LLUUID hostID, int channel, string name, string id,
|
||||
string msg)
|
||||
{
|
||||
|
||||
if ( m_listeners.Count < m_MaxListeners )
|
||||
if (m_listeners.Count < m_MaxListeners)
|
||||
{
|
||||
ListenerInfo isListener = IsListenerMatch(LLUUID.Zero.ToString(), itemID, channel, name, msg);
|
||||
|
||||
if(isListener == null)
|
||||
if (isListener == null)
|
||||
{
|
||||
int newHandle = GetNewHandle();
|
||||
|
||||
if (newHandle > -1)
|
||||
{
|
||||
|
||||
ListenerInfo li = new ListenerInfo(localID, newHandle, itemID, hostID, channel, name, id, msg);
|
||||
|
||||
lock (ListenersLock)
|
||||
@@ -308,13 +292,10 @@ namespace OpenSim.Region.Environment.Modules
|
||||
|
||||
return newHandle;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
public void Remove(int handle)
|
||||
@@ -324,7 +305,6 @@ namespace OpenSim.Region.Environment.Modules
|
||||
|
||||
private int GetNewHandle()
|
||||
{
|
||||
|
||||
for (int i = 0; i < int.MaxValue - 1; i++)
|
||||
{
|
||||
if (!m_listeners.ContainsKey(i))
|
||||
@@ -332,12 +312,10 @@ namespace OpenSim.Region.Environment.Modules
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
public bool IsListener(LLUUID hostID)
|
||||
{
|
||||
|
||||
foreach (ListenerInfo li in m_listeners.Values)
|
||||
{
|
||||
if (li.GetHostID().Equals(hostID))
|
||||
@@ -345,15 +323,13 @@ namespace OpenSim.Region.Environment.Modules
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public void Activate(int handle)
|
||||
{
|
||||
|
||||
ListenerInfo li;
|
||||
|
||||
if( m_listeners.TryGetValue(handle, out li) )
|
||||
if (m_listeners.TryGetValue(handle, out li))
|
||||
{
|
||||
li.Activate();
|
||||
}
|
||||
@@ -361,10 +337,9 @@ namespace OpenSim.Region.Environment.Modules
|
||||
|
||||
public void Dectivate(int handle)
|
||||
{
|
||||
|
||||
ListenerInfo li;
|
||||
|
||||
if( m_listeners.TryGetValue(handle, out li) )
|
||||
if (m_listeners.TryGetValue(handle, out li))
|
||||
{
|
||||
li.Deactivate();
|
||||
}
|
||||
@@ -372,40 +347,40 @@ namespace OpenSim.Region.Environment.Modules
|
||||
|
||||
// Theres probably a more clever and efficient way to
|
||||
// do this, maybe with regex.
|
||||
public ListenerInfo IsListenerMatch(string sourceItemID, LLUUID listenerKey, int channel, string name, string msg)
|
||||
public ListenerInfo IsListenerMatch(string sourceItemID, LLUUID listenerKey, int channel, string name,
|
||||
string msg)
|
||||
{
|
||||
|
||||
bool isMatch = true;
|
||||
|
||||
foreach (ListenerInfo li in m_listeners.Values)
|
||||
{
|
||||
if (li.GetHostID().Equals(listenerKey))
|
||||
{
|
||||
if ( li.IsActive() )
|
||||
if (li.IsActive())
|
||||
{
|
||||
if ( channel == li.GetChannel() )
|
||||
if (channel == li.GetChannel())
|
||||
{
|
||||
if ( (li.GetID().ToString().Length > 0) &&
|
||||
(!li.GetID().Equals(LLUUID.Zero)) )
|
||||
if ((li.GetID().ToString().Length > 0) &&
|
||||
(!li.GetID().Equals(LLUUID.Zero)))
|
||||
{
|
||||
if (!li.GetID().ToString().Equals(sourceItemID))
|
||||
{
|
||||
isMatch = false;
|
||||
}
|
||||
}
|
||||
if ( isMatch && (li.GetName().Length > 0) )
|
||||
if (isMatch && (li.GetName().Length > 0))
|
||||
{
|
||||
if ( li.GetName().Equals(name) )
|
||||
if (li.GetName().Equals(name))
|
||||
{
|
||||
isMatch = false;
|
||||
}
|
||||
}
|
||||
if ( isMatch )
|
||||
if (isMatch)
|
||||
{
|
||||
return new ListenerInfo(
|
||||
li.GetLocalID(), li.GetHandle(), li.GetItemID(), li.GetHostID(),
|
||||
li.GetChannel(), name, li.GetID(), msg, new LLUUID(sourceItemID)
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -413,35 +388,36 @@ namespace OpenSim.Region.Environment.Modules
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class ListenerInfo
|
||||
{
|
||||
private LLUUID m_itemID; // ID of the host script engine
|
||||
private LLUUID m_hostID; // ID of the host/scene part
|
||||
private LLUUID m_sourceItemID; // ID of the scenePart or avatar source of the message
|
||||
private int m_channel; // Channel
|
||||
private int m_handle; // Assigned handle of this listener
|
||||
private uint m_localID; // Local ID from script engine
|
||||
private string m_name; // Object name to filter messages from
|
||||
private LLUUID m_id; // ID to filter messages from
|
||||
private string m_message; // The message
|
||||
private bool m_active; // Listener is active or not
|
||||
|
||||
private LLUUID m_itemID; // ID of the host script engine
|
||||
private LLUUID m_hostID; // ID of the host/scene part
|
||||
private LLUUID m_sourceItemID; // ID of the scenePart or avatar source of the message
|
||||
private int m_channel; // Channel
|
||||
private int m_handle; // Assigned handle of this listener
|
||||
private uint m_localID; // Local ID from script engine
|
||||
private string m_name; // Object name to filter messages from
|
||||
private LLUUID m_id; // ID to filter messages from
|
||||
private string m_message; // The message
|
||||
private bool m_active; // Listener is active or not
|
||||
|
||||
public ListenerInfo(uint localID, int handle, LLUUID ItemID, LLUUID hostID, int channel, string name, LLUUID id, string message)
|
||||
public ListenerInfo(uint localID, int handle, LLUUID ItemID, LLUUID hostID, int channel, string name, LLUUID id,
|
||||
string message)
|
||||
{
|
||||
Initialise(localID, handle, ItemID, hostID, channel, name, id, message);
|
||||
}
|
||||
|
||||
public ListenerInfo(uint localID, int handle, LLUUID ItemID, LLUUID hostID, int channel, string name, LLUUID id, string message, LLUUID sourceItemID)
|
||||
public ListenerInfo(uint localID, int handle, LLUUID ItemID, LLUUID hostID, int channel, string name, LLUUID id,
|
||||
string message, LLUUID sourceItemID)
|
||||
{
|
||||
Initialise(localID, handle, ItemID, hostID, channel, name, id, message);
|
||||
m_sourceItemID = sourceItemID;
|
||||
}
|
||||
|
||||
private void Initialise(uint localID, int handle, LLUUID ItemID, LLUUID hostID, int channel, string name, LLUUID id, string message)
|
||||
private void Initialise(uint localID, int handle, LLUUID ItemID, LLUUID hostID, int channel, string name,
|
||||
LLUUID id, string message)
|
||||
{
|
||||
m_handle = handle;
|
||||
m_channel = channel;
|
||||
@@ -453,55 +429,65 @@ namespace OpenSim.Region.Environment.Modules
|
||||
m_active = true;
|
||||
m_localID = localID;
|
||||
}
|
||||
|
||||
public LLUUID GetItemID()
|
||||
{
|
||||
return m_itemID;
|
||||
}
|
||||
|
||||
public LLUUID GetHostID()
|
||||
{
|
||||
return m_hostID;
|
||||
}
|
||||
|
||||
public LLUUID GetSourceItemID()
|
||||
{
|
||||
return m_sourceItemID;
|
||||
}
|
||||
|
||||
public int GetChannel()
|
||||
{
|
||||
return m_channel;
|
||||
}
|
||||
|
||||
public uint GetLocalID()
|
||||
{
|
||||
return m_localID;
|
||||
}
|
||||
|
||||
public int GetHandle()
|
||||
{
|
||||
return m_handle;
|
||||
}
|
||||
|
||||
public string GetMessage()
|
||||
{
|
||||
return m_message;
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
public bool IsActive()
|
||||
{
|
||||
return m_active;
|
||||
}
|
||||
|
||||
public void Deactivate()
|
||||
{
|
||||
m_active = false;
|
||||
}
|
||||
|
||||
public void Activate()
|
||||
{
|
||||
m_active = true;
|
||||
}
|
||||
|
||||
public LLUUID GetID()
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -26,20 +26,15 @@
|
||||
*
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
using libsecondlife;
|
||||
using OpenSim.Framework.Interfaces;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
using OpenSim.Region.Environment.Scenes;
|
||||
using OpenSim.Framework.Servers;
|
||||
using Nwc.XmlRpc;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using libsecondlife;
|
||||
using Nini.Config;
|
||||
using Nwc.XmlRpc;
|
||||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
using OpenSim.Region.Environment.Scenes;
|
||||
|
||||
/*****************************************************
|
||||
*
|
||||
@@ -73,6 +68,7 @@ using Nini.Config;
|
||||
* llCloseRemoteDataChannel
|
||||
*
|
||||
* **************************************************/
|
||||
|
||||
namespace OpenSim.Region.Environment.Modules
|
||||
{
|
||||
public class XMLRPCModule : IRegionModule, IXMLRPC
|
||||
@@ -83,7 +79,7 @@ namespace OpenSim.Region.Environment.Modules
|
||||
private string m_name = "XMLRPCModule";
|
||||
private int RemoteReplyScriptWait = 100;
|
||||
private int RemoteReplyScriptTimeout = 300;
|
||||
|
||||
|
||||
// <channel id, RPCChannelInfo>
|
||||
private Dictionary<LLUUID, RPCChannelInfo> m_openChannels;
|
||||
|
||||
@@ -106,7 +102,7 @@ namespace OpenSim.Region.Environment.Modules
|
||||
// Start http server
|
||||
// Attach xmlrpc handlers
|
||||
BaseHttpServer httpServer = new BaseHttpServer(20800);
|
||||
httpServer.AddXmlRPCHandler("llRemoteData", this.XmlRpcRemoteData);
|
||||
httpServer.AddXmlRPCHandler("llRemoteData", XmlRpcRemoteData);
|
||||
httpServer.Start();
|
||||
}
|
||||
|
||||
@@ -141,6 +137,7 @@ namespace OpenSim.Region.Environment.Modules
|
||||
* current channel and assign a new one.
|
||||
*
|
||||
* ********************************************/
|
||||
|
||||
public LLUUID OpenXMLRPCChannel(uint localID, LLUUID itemID)
|
||||
{
|
||||
LLUUID channel = null;
|
||||
@@ -156,7 +153,7 @@ namespace OpenSim.Region.Environment.Modules
|
||||
}
|
||||
}
|
||||
|
||||
if ( (channel == null) || (channel.Equals(LLUUID.Zero)) )
|
||||
if ((channel == null) || (channel.Equals(LLUUID.Zero)))
|
||||
{
|
||||
channel = LLUUID.Random();
|
||||
RPCChannelInfo rpcChanInfo = new RPCChannelInfo(localID, itemID, channel);
|
||||
@@ -164,7 +161,6 @@ namespace OpenSim.Region.Environment.Modules
|
||||
{
|
||||
m_openChannels.Add(channel, rpcChanInfo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return channel;
|
||||
@@ -176,6 +172,7 @@ namespace OpenSim.Region.Environment.Modules
|
||||
* Response to RPC message
|
||||
*
|
||||
*********************************************/
|
||||
|
||||
public void RemoteDataReply(string channel, string message_id, string sdata, int idata)
|
||||
{
|
||||
RPCRequestInfo rpcInfo;
|
||||
@@ -191,7 +188,6 @@ namespace OpenSim.Region.Environment.Modules
|
||||
m_pendingResponse.Remove(message_key);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**********************************************
|
||||
@@ -200,41 +196,44 @@ namespace OpenSim.Region.Environment.Modules
|
||||
* Remove channel from dictionary
|
||||
*
|
||||
*********************************************/
|
||||
|
||||
public void CloseXMLRPCChannel(LLUUID channelKey)
|
||||
{
|
||||
if(m_openChannels.ContainsKey(channelKey))
|
||||
if (m_openChannels.ContainsKey(channelKey))
|
||||
m_openChannels.Remove(channelKey);
|
||||
}
|
||||
|
||||
|
||||
public XmlRpcResponse XmlRpcRemoteData(XmlRpcRequest request)
|
||||
{
|
||||
|
||||
XmlRpcResponse response = new XmlRpcResponse();
|
||||
|
||||
Hashtable requestData = (Hashtable)request.Params[0];
|
||||
bool GoodXML = (requestData.Contains("Channel") && requestData.Contains("IntValue") && requestData.Contains("StringValue"));
|
||||
Hashtable requestData = (Hashtable) request.Params[0];
|
||||
bool GoodXML = (requestData.Contains("Channel") && requestData.Contains("IntValue") &&
|
||||
requestData.Contains("StringValue"));
|
||||
|
||||
if (GoodXML)
|
||||
{
|
||||
LLUUID channel = new LLUUID((string)requestData["Channel"]);
|
||||
LLUUID channel = new LLUUID((string) requestData["Channel"]);
|
||||
RPCChannelInfo rpcChanInfo;
|
||||
if (m_openChannels.TryGetValue(channel, out rpcChanInfo))
|
||||
{
|
||||
string intVal = (string)requestData["IntValue"];
|
||||
string strVal = (string)requestData["StringValue"];
|
||||
string intVal = (string) requestData["IntValue"];
|
||||
string strVal = (string) requestData["StringValue"];
|
||||
|
||||
RPCRequestInfo rpcInfo;
|
||||
|
||||
lock (XMLRPCListLock)
|
||||
{
|
||||
rpcInfo = new RPCRequestInfo(rpcChanInfo.GetLocalID(), rpcChanInfo.GetItemID(), channel, strVal, intVal);
|
||||
rpcInfo =
|
||||
new RPCRequestInfo(rpcChanInfo.GetLocalID(), rpcChanInfo.GetItemID(), channel, strVal,
|
||||
intVal);
|
||||
rpcQueue.Enqueue(rpcInfo);
|
||||
}
|
||||
|
||||
int timeoutCtr = 0;
|
||||
|
||||
while(!rpcInfo.IsProcessed() && (timeoutCtr < RemoteReplyScriptTimeout))
|
||||
while (!rpcInfo.IsProcessed() && (timeoutCtr < RemoteReplyScriptTimeout))
|
||||
{
|
||||
Thread.Sleep(RemoteReplyScriptWait);
|
||||
timeoutCtr += RemoteReplyScriptWait;
|
||||
@@ -252,13 +251,11 @@ namespace OpenSim.Region.Environment.Modules
|
||||
m_pendingResponse.Remove(rpcInfo.GetMessageID());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
response.SetFault(-1, "Invalid channel");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return response;
|
||||
@@ -278,7 +275,6 @@ namespace OpenSim.Region.Environment.Modules
|
||||
return rpcInfo;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**************************************************************
|
||||
@@ -288,6 +284,7 @@ namespace OpenSim.Region.Environment.Modules
|
||||
* Holds details about incoming requests until they are picked
|
||||
* from the queue by LSLLongCmdHandler
|
||||
* ***********************************************************/
|
||||
|
||||
public class RPCRequestInfo
|
||||
{
|
||||
private string m_StrVal;
|
||||
@@ -315,6 +312,7 @@ namespace OpenSim.Region.Environment.Modules
|
||||
{
|
||||
return m_processed;
|
||||
}
|
||||
|
||||
public LLUUID GetChannelKey()
|
||||
{
|
||||
return m_ChannelKey;
|
||||
@@ -324,36 +322,41 @@ namespace OpenSim.Region.Environment.Modules
|
||||
{
|
||||
m_processed = processed;
|
||||
}
|
||||
|
||||
public void SetRetval(string resp)
|
||||
{
|
||||
m_resp = resp;
|
||||
}
|
||||
|
||||
public string GetRetval()
|
||||
{
|
||||
return m_resp;
|
||||
}
|
||||
|
||||
public uint GetLocalID()
|
||||
{
|
||||
return m_localID;
|
||||
}
|
||||
|
||||
public LLUUID GetItemID()
|
||||
{
|
||||
return m_ItemID;
|
||||
}
|
||||
|
||||
public string GetStrVal()
|
||||
{
|
||||
return m_StrVal;
|
||||
}
|
||||
|
||||
public int GetIntValue()
|
||||
{
|
||||
return int.Parse(m_IntVal);
|
||||
}
|
||||
|
||||
public LLUUID GetMessageID()
|
||||
{
|
||||
return m_MessageID;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class RPCChannelInfo
|
||||
@@ -383,7 +386,5 @@ namespace OpenSim.Region.Environment.Modules
|
||||
{
|
||||
return m_localID;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -29,11 +29,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using libsecondlife;
|
||||
using OpenSim.Framework.Interfaces;
|
||||
using Nini.Config;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
using OpenSim.Region.Environment.Scenes;
|
||||
using OpenSim.Framework;
|
||||
using Nini.Config;
|
||||
|
||||
namespace OpenSim.Region.Environment.Modules
|
||||
{
|
||||
@@ -200,4 +199,4 @@ namespace OpenSim.Region.Environment.Modules
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user