diff --git a/.gitignore b/.gitignore
index b6b5582b0d..8bd53864b3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,6 +9,12 @@
*.pdb
*.pidb
*.dll.build
+*/*/obj
+*/*/*/obj
+*/*/*/*/obj
+*/*/*/*/*/obj
+*/*/*/*/*/*/obj
+*/*/*/*/*/*/*/obj
*/*/bin
*/*/*/bin
*/*/*/*/bin
diff --git a/.nant/local.include b/.nant/local.include
deleted file mode 100644
index 114c12d28f..0000000000
--- a/.nant/local.include
+++ /dev/null
@@ -1,312 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs
index 2dec72d1e0..c1a52211ec 100644
--- a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs
+++ b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs
@@ -570,6 +570,7 @@ namespace OpenSim.Client.MXP.ClientStack
public event GenericMessage OnGenericMessage;
public event ImprovedInstantMessage OnInstantMessage;
public event ChatMessage OnChatFromClient;
+ public event ChatMessageRaw OnChatFromClientRaw;
public event TextureRequest OnRequestTexture;
public event RezObject OnRezObject;
public event ModifyTerrain OnModifyTerrain;
@@ -600,6 +601,7 @@ namespace OpenSim.Client.MXP.ClientStack
public event GenericCall1 OnCompleteMovementToRegion;
public event UpdateAgent OnPreAgentUpdate;
public event UpdateAgent OnAgentUpdate;
+ public event UpdateAgentRaw OnAgentUpdateRaw;
public event AgentRequestSit OnAgentRequestSit;
public event AgentSit OnAgentSit;
public event AvatarPickerRequest OnAvatarPickerRequest;
diff --git a/OpenSim/Client/Sirikata/ClientStack/SirikataClientView.cs b/OpenSim/Client/Sirikata/ClientStack/SirikataClientView.cs
index 9cb21720ec..031df5d8bd 100644
--- a/OpenSim/Client/Sirikata/ClientStack/SirikataClientView.cs
+++ b/OpenSim/Client/Sirikata/ClientStack/SirikataClientView.cs
@@ -216,6 +216,7 @@ namespace OpenSim.Client.Sirikata.ClientStack
public event GenericMessage OnGenericMessage;
public event ImprovedInstantMessage OnInstantMessage;
public event ChatMessage OnChatFromClient;
+ public event ChatMessageRaw OnChatFromClientRaw;
public event TextureRequest OnRequestTexture;
public event RezObject OnRezObject;
public event ModifyTerrain OnModifyTerrain;
@@ -246,6 +247,7 @@ namespace OpenSim.Client.Sirikata.ClientStack
public event GenericCall1 OnCompleteMovementToRegion;
public event UpdateAgent OnPreAgentUpdate;
public event UpdateAgent OnAgentUpdate;
+ public event UpdateAgentRaw OnAgentUpdateRaw;
public event AgentRequestSit OnAgentRequestSit;
public event AgentSit OnAgentSit;
public event AvatarPickerRequest OnAvatarPickerRequest;
diff --git a/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs b/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs
index a427dd3b81..9396c520f9 100644
--- a/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs
+++ b/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs
@@ -219,6 +219,7 @@ namespace OpenSim.Client.VWoHTTP.ClientStack
public event GenericMessage OnGenericMessage = delegate { };
public event ImprovedInstantMessage OnInstantMessage = delegate { };
public event ChatMessage OnChatFromClient = delegate { };
+ public event ChatMessageRaw OnChatFromClientRaw = delegate { };
public event TextureRequest OnRequestTexture = delegate { };
public event RezObject OnRezObject = delegate { };
public event ModifyTerrain OnModifyTerrain = delegate { };
@@ -249,6 +250,7 @@ namespace OpenSim.Client.VWoHTTP.ClientStack
public event GenericCall1 OnCompleteMovementToRegion = delegate { };
public event UpdateAgent OnPreAgentUpdate;
public event UpdateAgent OnAgentUpdate = delegate { };
+ public event UpdateAgentRaw OnAgentUpdateRaw = delegate { };
public event AgentRequestSit OnAgentRequestSit = delegate { };
public event AgentSit OnAgentSit = delegate { };
public event AvatarPickerRequest OnAvatarPickerRequest = delegate { };
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs
index 4f6f709adf..3a0fe86c97 100644
--- a/OpenSim/Framework/IClientAPI.cs
+++ b/OpenSim/Framework/IClientAPI.cs
@@ -38,6 +38,7 @@ namespace OpenSim.Framework
public delegate void ViewerEffectEventHandler(IClientAPI sender, List args);
public delegate void ChatMessage(Object sender, OSChatMessage e);
+ public delegate void ChatMessageRaw(Object sender, byte[] chatData);
public delegate void GenericMessage(Object sender, string method, List args);
@@ -149,6 +150,7 @@ namespace OpenSim.Framework
public delegate void NewAvatar(IClientAPI remoteClient, UUID agentID, bool status);
public delegate void UpdateAgent(IClientAPI remoteClient, AgentUpdateArgs agentData);
+ public delegate void UpdateAgentRaw(IClientAPI remoteClient, byte[] agentData);
public delegate void AgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset);
@@ -848,6 +850,7 @@ namespace OpenSim.Framework
event ImprovedInstantMessage OnInstantMessage;
// [Obsolete("LLClientView Specific - Replace with more bare-bones arguments. Rename OnChat.")]
event ChatMessage OnChatFromClient;
+ event ChatMessageRaw OnChatFromClientRaw;
// [Obsolete("LLClientView Specific - Replace with more bare-bones arguments.")]
event TextureRequest OnRequestTexture;
// [Obsolete("LLClientView Specific - Remove bitbuckets. Adam, can you be more specific here.. as I don't see any bit buckets.")]
@@ -883,6 +886,7 @@ namespace OpenSim.Framework
event GenericCall1 OnCompleteMovementToRegion;
event UpdateAgent OnPreAgentUpdate;
event UpdateAgent OnAgentUpdate;
+ event UpdateAgentRaw OnAgentUpdateRaw;
event AgentRequestSit OnAgentRequestSit;
event AgentSit OnAgentSit;
event AvatarPickerRequest OnAvatarPickerRequest;
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index a9b5c2b1da..af1910dd9f 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -48,6 +48,7 @@ using OpenSim.Services.Interfaces;
using Timer = System.Timers.Timer;
using AssetLandmark = OpenSim.Framework.AssetLandmark;
using Nini.Config;
+using System.Linq;
namespace OpenSim.Region.ClientStack.LindenUDP
{
@@ -112,6 +113,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public event ViewerEffectEventHandler OnViewerEffect;
public event ImprovedInstantMessage OnInstantMessage;
public event ChatMessage OnChatFromClient;
+ public event ChatMessageRaw OnChatFromClientRaw;
public event TextureRequest OnRequestTexture;
public event RezObject OnRezObject;
public event DeRezObject OnDeRezObject;
@@ -129,6 +131,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public event GenericCall1 OnCompleteMovementToRegion;
public event UpdateAgent OnPreAgentUpdate;
public event UpdateAgent OnAgentUpdate;
+ public event UpdateAgentRaw OnAgentUpdateRaw;
public event AgentRequestSit OnAgentRequestSit;
public event AgentSit OnAgentSit;
public event AvatarPickerRequest OnAvatarPickerRequest;
@@ -356,7 +359,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private int m_moneyBalance;
private int m_animationSequenceNumber = 1;
private bool m_SendLogoutPacketWhenClosing = true;
- private AgentUpdateArgs lastarg;
+ private byte[] m_lastAgentUpdate;
private bool m_IsActive = true;
private bool m_IsLoggingOut = false;
@@ -4836,9 +4839,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private bool HandleAgentUpdate(IClientAPI sener, Packet Pack)
{
- if (OnAgentUpdate != null)
+ if (OnAgentUpdate != null || OnAgentUpdateRaw != null)
{
- bool update = false;
AgentUpdatePacket agenUpdate = (AgentUpdatePacket)Pack;
#region Packet Session and User Check
@@ -4847,60 +4849,68 @@ namespace OpenSim.Region.ClientStack.LindenUDP
#endregion
AgentUpdatePacket.AgentDataBlock x = agenUpdate.AgentData;
+ byte[] xb = new byte[x.Length];
+ int i = 0;
+ x.ToBytes(xb, ref i);
- // We can only check when we have something to check
- // against.
+ // If there was a previous update and this update is exactly the same, skip it
+ if (m_lastAgentUpdate != null && Enumerable.SequenceEqual(xb, m_lastAgentUpdate))
+ return true;
- if (lastarg != null)
+ /*
+ // What is different?? (only interesting for client managers)
+ if(m_scene.IsSyncedClient() && m_lastAgentUpdate != null)
{
- update =
- (
- (x.BodyRotation != lastarg.BodyRotation) ||
- (x.CameraAtAxis != lastarg.CameraAtAxis) ||
- (x.CameraCenter != lastarg.CameraCenter) ||
- (x.CameraLeftAxis != lastarg.CameraLeftAxis) ||
- (x.CameraUpAxis != lastarg.CameraUpAxis) ||
- (x.ControlFlags != lastarg.ControlFlags) ||
- (x.Far != lastarg.Far) ||
- (x.Flags != lastarg.Flags) ||
- (x.State != lastarg.State) ||
- (x.HeadRotation != lastarg.HeadRotation) ||
- (x.SessionID != lastarg.SessionID) ||
- (x.AgentID != lastarg.AgentID)
- );
+ AgentUpdatePacket.AgentDataBlock lastarg = new AgentUpdatePacket.AgentDataBlock();
+ i = 0;
+ lastarg.FromBytes(m_lastAgentUpdate, ref i);
+
+ if(x.BodyRotation != lastarg.BodyRotation) m_log.Warn("BodyRotation");
+ if(x.CameraAtAxis != lastarg.CameraAtAxis) m_log.Warn("CameraAtAxis");
+ if(x.CameraCenter != lastarg.CameraCenter) m_log.Warn("CameraCenter");
+ if(x.CameraLeftAxis != lastarg.CameraLeftAxis) m_log.Warn("CameraLeftAxis");
+ if(x.CameraUpAxis != lastarg.CameraUpAxis) m_log.Warn("CameraUpAxis");
+ if(x.ControlFlags != lastarg.ControlFlags) m_log.Warn("ControlFlags");
+ if(x.Far != lastarg.Far) m_log.Warn("Far");
+ if(x.Flags != lastarg.Flags) m_log.Warn("Flags");
+ if(x.State != lastarg.State) m_log.Warn("State");
+ if(x.HeadRotation != lastarg.HeadRotation) m_log.Warn("HeadRotation");
+ if(x.SessionID != lastarg.SessionID) m_log.Warn("SessionID");
+ if(x.AgentID != lastarg.AgentID) m_log.Warn("AgentID");
}
- else
- update = true;
+ * */
- // These should be ordered from most-likely to
- // least likely to change. I've made an initial
- // guess at that.
+ // save this set of arguments for next time
+ m_lastAgentUpdate = xb;
- if (update)
+ // If we have a raw handler, call it
+ UpdateAgentRaw handlerAgentUpdateRaw = OnAgentUpdateRaw;
+ if (handlerAgentUpdateRaw != null)
{
- AgentUpdateArgs arg = new AgentUpdateArgs();
- arg.AgentID = x.AgentID;
- arg.BodyRotation = x.BodyRotation;
- arg.CameraAtAxis = x.CameraAtAxis;
- arg.CameraCenter = x.CameraCenter;
- arg.CameraLeftAxis = x.CameraLeftAxis;
- arg.CameraUpAxis = x.CameraUpAxis;
- arg.ControlFlags = x.ControlFlags;
- arg.Far = x.Far;
- arg.Flags = x.Flags;
- arg.HeadRotation = x.HeadRotation;
- arg.SessionID = x.SessionID;
- arg.State = x.State;
- UpdateAgent handlerAgentUpdate = OnAgentUpdate;
- lastarg = arg; // save this set of arguments for nexttime
- if (handlerAgentUpdate != null)
- {
- OnPreAgentUpdate(this, arg);
- OnAgentUpdate(this, arg);
- }
-
- handlerAgentUpdate = null;
+ handlerAgentUpdateRaw(this, xb);
+ handlerAgentUpdateRaw = null;
+ return true;
}
+
+ AgentUpdateArgs arg = new AgentUpdateArgs();
+ arg.AgentID = x.AgentID;
+ arg.BodyRotation = x.BodyRotation;
+ arg.CameraAtAxis = x.CameraAtAxis;
+ arg.CameraCenter = x.CameraCenter;
+ arg.CameraLeftAxis = x.CameraLeftAxis;
+ arg.CameraUpAxis = x.CameraUpAxis;
+ arg.ControlFlags = x.ControlFlags;
+ arg.Far = x.Far;
+ arg.Flags = x.Flags;
+ arg.HeadRotation = x.HeadRotation;
+ arg.SessionID = x.SessionID;
+ arg.State = x.State;
+
+ UpdateAgent handlerAgentUpdate = OnAgentUpdate;
+ if (handlerAgentUpdate != null)
+ OnAgentUpdate(this, arg);
+
+ handlerAgentUpdate = null;
}
return true;
@@ -5155,6 +5165,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP
int channel = inchatpack.ChatData.Channel;
+ // If we have a raw handler, call it
+ ChatMessageRaw handlerChatFromClientRaw = OnChatFromClientRaw;
+ if (handlerChatFromClientRaw != null)
+ {
+ ChatFromViewerPacket.ChatDataBlock x = inchatpack.ChatData;
+ byte[] xb = new byte[x.Length];
+ int i = 0;
+ x.ToBytes(xb, ref i);
+
+ handlerChatFromClientRaw(this, xb);
+ handlerChatFromClientRaw = null;
+ return true;
+ }
if (OnChatFromClient != null)
{
OSChatMessage args = new OSChatMessage();
diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/Properties/AssemblyInfo.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000000..eb7af058e1
--- /dev/null
+++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/Properties/AssemblyInfo.cs
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSim Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+// General information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("OpenSim.Region.Examples.RegionSyncModule")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("http://opensimulator.org")]
+[assembly: AssemblyProduct("OpenSim.Region.Examples.RegionSyncModule")]
+[assembly: AssemblyCopyright("Copyright (c) 2008")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("f0caca77-7818-4a43-9200-0a8548009a05")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("0.6.4.*")]
+[assembly: AssemblyVersion("0.6.4.*")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncAvatar.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncAvatar.cs
new file mode 100644
index 0000000000..8e876c2952
--- /dev/null
+++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncAvatar.cs
@@ -0,0 +1,1201 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Net;
+using OpenMetaverse;
+using OpenMetaverse.Packets;
+using OpenSim.Framework;
+using OpenSim.Region.Framework.Scenes;
+
+namespace OpenSim.Region.Examples.RegionSyncModule
+{
+ public class RegionSyncAvatar : IClientAPI
+ {
+ private uint movementFlag = 0;
+ private short flyState = 0;
+ private Quaternion bodyDirection = Quaternion.Identity;
+ private short count = 0;
+ private short frame = 0;
+
+// disable warning: public events, part of the public API
+#pragma warning disable 67
+
+ public event Action OnLogout;
+ public event ObjectPermissions OnObjectPermissions;
+
+ public event MoneyTransferRequest OnMoneyTransferRequest;
+ public event ParcelBuy OnParcelBuy;
+ public event Action OnConnectionClosed;
+
+ public event ImprovedInstantMessage OnInstantMessage;
+ public event ChatMessage OnChatFromClient;
+ public event ChatMessageRaw OnChatFromClientRaw;
+ public event TextureRequest OnRequestTexture;
+ public event RezObject OnRezObject;
+ public event ModifyTerrain OnModifyTerrain;
+ public event BakeTerrain OnBakeTerrain;
+ public event SetAppearance OnSetAppearance;
+ public event AvatarNowWearing OnAvatarNowWearing;
+ public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv;
+ public event RezMultipleAttachmentsFromInv OnRezMultipleAttachmentsFromInv;
+ public event UUIDNameRequest OnDetachAttachmentIntoInv;
+ public event ObjectAttach OnObjectAttach;
+ public event ObjectDeselect OnObjectDetach;
+ public event ObjectDrop OnObjectDrop;
+ public event StartAnim OnStartAnim;
+ public event StopAnim OnStopAnim;
+ public event LinkObjects OnLinkObjects;
+ public event DelinkObjects OnDelinkObjects;
+ public event RequestMapBlocks OnRequestMapBlocks;
+ public event RequestMapName OnMapNameRequest;
+ public event TeleportLocationRequest OnTeleportLocationRequest;
+ public event TeleportLandmarkRequest OnTeleportLandmarkRequest;
+ public event DisconnectUser OnDisconnectUser;
+ public event RequestAvatarProperties OnRequestAvatarProperties;
+ public event SetAlwaysRun OnSetAlwaysRun;
+
+ public event DeRezObject OnDeRezObject;
+ public event Action OnRegionHandShakeReply;
+ public event GenericCall2 OnRequestWearables;
+ public event GenericCall1 OnCompleteMovementToRegion;
+ public event UpdateAgent OnPreAgentUpdate;
+ public event UpdateAgent OnAgentUpdate;
+ public event UpdateAgentRaw OnAgentUpdateRaw;
+ public event AgentRequestSit OnAgentRequestSit;
+ public event AgentSit OnAgentSit;
+ public event AvatarPickerRequest OnAvatarPickerRequest;
+ public event Action OnRequestAvatarsData;
+ public event AddNewPrim OnAddPrim;
+ public event RequestGodlikePowers OnRequestGodlikePowers;
+ public event GodKickUser OnGodKickUser;
+ public event ObjectDuplicate OnObjectDuplicate;
+ public event GrabObject OnGrabObject;
+ public event DeGrabObject OnDeGrabObject;
+ public event MoveObject OnGrabUpdate;
+ public event SpinStart OnSpinStart;
+ public event SpinObject OnSpinUpdate;
+ public event SpinStop OnSpinStop;
+ public event ViewerEffectEventHandler OnViewerEffect;
+
+ public event FetchInventory OnAgentDataUpdateRequest;
+ public event TeleportLocationRequest OnSetStartLocationRequest;
+
+ public event UpdateShape OnUpdatePrimShape;
+ public event ObjectExtraParams OnUpdateExtraParams;
+ public event RequestObjectPropertiesFamily OnRequestObjectPropertiesFamily;
+ public event ObjectRequest OnObjectRequest;
+ public event ObjectSelect OnObjectSelect;
+ public event GenericCall7 OnObjectDescription;
+ public event GenericCall7 OnObjectName;
+ public event GenericCall7 OnObjectClickAction;
+ public event GenericCall7 OnObjectMaterial;
+ public event UpdatePrimFlags OnUpdatePrimFlags;
+ public event UpdatePrimTexture OnUpdatePrimTexture;
+ public event UpdateVector OnUpdatePrimGroupPosition;
+ public event UpdateVector OnUpdatePrimSinglePosition;
+ public event UpdatePrimRotation OnUpdatePrimGroupRotation;
+ public event UpdatePrimSingleRotationPosition OnUpdatePrimSingleRotationPosition;
+ public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation;
+ public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation;
+ public event UpdateVector OnUpdatePrimScale;
+ public event UpdateVector OnUpdatePrimGroupScale;
+ public event StatusChange OnChildAgentStatus;
+ public event GenericCall2 OnStopMovement;
+ public event Action OnRemoveAvatar;
+
+ public event CreateNewInventoryItem OnCreateNewInventoryItem;
+ public event CreateInventoryFolder OnCreateNewInventoryFolder;
+ public event UpdateInventoryFolder OnUpdateInventoryFolder;
+ public event MoveInventoryFolder OnMoveInventoryFolder;
+ public event RemoveInventoryFolder OnRemoveInventoryFolder;
+ public event RemoveInventoryItem OnRemoveInventoryItem;
+ public event FetchInventoryDescendents OnFetchInventoryDescendents;
+ public event PurgeInventoryDescendents OnPurgeInventoryDescendents;
+ public event FetchInventory OnFetchInventory;
+ public event RequestTaskInventory OnRequestTaskInventory;
+ public event UpdateInventoryItem OnUpdateInventoryItem;
+ public event CopyInventoryItem OnCopyInventoryItem;
+ public event MoveInventoryItem OnMoveInventoryItem;
+ public event UDPAssetUploadRequest OnAssetUploadRequest;
+ public event RequestTerrain OnRequestTerrain;
+ public event RequestTerrain OnUploadTerrain;
+ public event XferReceive OnXferReceive;
+ public event RequestXfer OnRequestXfer;
+ public event ConfirmXfer OnConfirmXfer;
+ public event AbortXfer OnAbortXfer;
+ public event RezScript OnRezScript;
+ public event UpdateTaskInventory OnUpdateTaskInventory;
+ public event MoveTaskInventory OnMoveTaskItem;
+ public event RemoveTaskInventory OnRemoveTaskItem;
+ public event RequestAsset OnRequestAsset;
+ public event GenericMessage OnGenericMessage;
+ public event UUIDNameRequest OnNameFromUUIDRequest;
+ public event UUIDNameRequest OnUUIDGroupNameRequest;
+
+ public event ParcelPropertiesRequest OnParcelPropertiesRequest;
+ public event ParcelDivideRequest OnParcelDivideRequest;
+ public event ParcelJoinRequest OnParcelJoinRequest;
+ public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest;
+ public event ParcelAbandonRequest OnParcelAbandonRequest;
+ public event ParcelGodForceOwner OnParcelGodForceOwner;
+ public event ParcelReclaim OnParcelReclaim;
+ public event ParcelReturnObjectsRequest OnParcelReturnObjectsRequest;
+ public event ParcelAccessListRequest OnParcelAccessListRequest;
+ public event ParcelAccessListUpdateRequest OnParcelAccessListUpdateRequest;
+ public event ParcelSelectObjects OnParcelSelectObjects;
+ public event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest;
+ public event ParcelDeedToGroup OnParcelDeedToGroup;
+ public event ObjectDeselect OnObjectDeselect;
+ public event RegionInfoRequest OnRegionInfoRequest;
+ public event EstateCovenantRequest OnEstateCovenantRequest;
+ public event EstateChangeInfo OnEstateChangeInfo;
+
+ public event ObjectDuplicateOnRay OnObjectDuplicateOnRay;
+
+ public event FriendActionDelegate OnApproveFriendRequest;
+ public event FriendActionDelegate OnDenyFriendRequest;
+ public event FriendshipTermination OnTerminateFriendship;
+ public event GrantUserFriendRights OnGrantUserRights;
+
+ public event EconomyDataRequest OnEconomyDataRequest;
+ public event MoneyBalanceRequest OnMoneyBalanceRequest;
+ public event UpdateAvatarProperties OnUpdateAvatarProperties;
+
+ public event ObjectIncludeInSearch OnObjectIncludeInSearch;
+ public event UUIDNameRequest OnTeleportHomeRequest;
+
+ public event ScriptAnswer OnScriptAnswer;
+ public event RequestPayPrice OnRequestPayPrice;
+ public event ObjectSaleInfo OnObjectSaleInfo;
+ public event ObjectBuy OnObjectBuy;
+ public event BuyObjectInventory OnBuyObjectInventory;
+ public event AgentSit OnUndo;
+ public event AgentSit OnRedo;
+ public event LandUndo OnLandUndo;
+
+ public event ForceReleaseControls OnForceReleaseControls;
+
+ public event GodLandStatRequest OnLandStatRequest;
+ public event RequestObjectPropertiesFamily OnObjectGroupRequest;
+
+ public event DetailedEstateDataRequest OnDetailedEstateDataRequest;
+ public event SetEstateFlagsRequest OnSetEstateFlagsRequest;
+ public event SetEstateTerrainBaseTexture OnSetEstateTerrainBaseTexture;
+ public event SetEstateTerrainDetailTexture OnSetEstateTerrainDetailTexture;
+ public event SetEstateTerrainTextureHeights OnSetEstateTerrainTextureHeights;
+ public event CommitEstateTerrainTextureRequest OnCommitEstateTerrainTextureRequest;
+ public event SetRegionTerrainSettings OnSetRegionTerrainSettings;
+ public event EstateRestartSimRequest OnEstateRestartSimRequest;
+ public event EstateChangeCovenantRequest OnEstateChangeCovenantRequest;
+ public event UpdateEstateAccessDeltaRequest OnUpdateEstateAccessDeltaRequest;
+ public event SimulatorBlueBoxMessageRequest OnSimulatorBlueBoxMessageRequest;
+ public event EstateBlueBoxMessageRequest OnEstateBlueBoxMessageRequest;
+ public event EstateDebugRegionRequest OnEstateDebugRegionRequest;
+ public event EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest;
+ public event EstateTeleportAllUsersHomeRequest OnEstateTeleportAllUsersHomeRequest;
+ public event ScriptReset OnScriptReset;
+ public event GetScriptRunning OnGetScriptRunning;
+ public event SetScriptRunning OnSetScriptRunning;
+ public event UpdateVector OnAutoPilotGo;
+
+ public event TerrainUnacked OnUnackedTerrain;
+
+ public event RegionHandleRequest OnRegionHandleRequest;
+ public event ParcelInfoRequest OnParcelInfoRequest;
+
+ public event ActivateGesture OnActivateGesture;
+ public event DeactivateGesture OnDeactivateGesture;
+ public event ObjectOwner OnObjectOwner;
+
+ public event DirPlacesQuery OnDirPlacesQuery;
+ public event DirFindQuery OnDirFindQuery;
+ public event DirLandQuery OnDirLandQuery;
+ public event DirPopularQuery OnDirPopularQuery;
+ public event DirClassifiedQuery OnDirClassifiedQuery;
+ public event EventInfoRequest OnEventInfoRequest;
+ public event ParcelSetOtherCleanTime OnParcelSetOtherCleanTime;
+
+ public event MapItemRequest OnMapItemRequest;
+
+ public event OfferCallingCard OnOfferCallingCard;
+ public event AcceptCallingCard OnAcceptCallingCard;
+ public event DeclineCallingCard OnDeclineCallingCard;
+ public event SoundTrigger OnSoundTrigger;
+
+ public event StartLure OnStartLure;
+ public event TeleportLureRequest OnTeleportLureRequest;
+ public event NetworkStats OnNetworkStatsUpdate;
+
+ public event ClassifiedInfoRequest OnClassifiedInfoRequest;
+ public event ClassifiedInfoUpdate OnClassifiedInfoUpdate;
+ public event ClassifiedDelete OnClassifiedDelete;
+ public event ClassifiedDelete OnClassifiedGodDelete;
+
+ public event EventNotificationAddRequest OnEventNotificationAddRequest;
+ public event EventNotificationRemoveRequest OnEventNotificationRemoveRequest;
+ public event EventGodDelete OnEventGodDelete;
+
+ public event ParcelDwellRequest OnParcelDwellRequest;
+ public event UserInfoRequest OnUserInfoRequest;
+ public event UpdateUserInfo OnUpdateUserInfo;
+
+ public event RetrieveInstantMessages OnRetrieveInstantMessages;
+
+ public event PickDelete OnPickDelete;
+ public event PickGodDelete OnPickGodDelete;
+ public event PickInfoUpdate OnPickInfoUpdate;
+ public event AvatarNotesUpdate OnAvatarNotesUpdate;
+
+ public event MuteListRequest OnMuteListRequest;
+
+ public event AvatarInterestUpdate OnAvatarInterestUpdate;
+
+ public event PlacesQuery OnPlacesQuery;
+
+ public event FindAgentUpdate OnFindAgent;
+ public event TrackAgentUpdate OnTrackAgent;
+ public event NewUserReport OnUserReport;
+ public event SaveStateHandler OnSaveState;
+ public event GroupAccountSummaryRequest OnGroupAccountSummaryRequest;
+ public event GroupAccountDetailsRequest OnGroupAccountDetailsRequest;
+ public event GroupAccountTransactionsRequest OnGroupAccountTransactionsRequest;
+ public event FreezeUserUpdate OnParcelFreezeUser;
+ public event EjectUserUpdate OnParcelEjectUser;
+ public event ParcelBuyPass OnParcelBuyPass;
+ public event ParcelGodMark OnParcelGodMark;
+ public event GroupActiveProposalsRequest OnGroupActiveProposalsRequest;
+ public event GroupVoteHistoryRequest OnGroupVoteHistoryRequest;
+ public event SimWideDeletesDelegate OnSimWideDeletes;
+ public event SendPostcard OnSendPostcard;
+ public event MuteListEntryUpdate OnUpdateMuteListEntry;
+ public event MuteListEntryRemove OnRemoveMuteListEntry;
+ public event GodlikeMessage onGodlikeMessage;
+ public event GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate;
+
+#pragma warning restore 67
+
+ private Scene m_scene;
+ private UUID m_agentID;
+ private string m_firstName;
+ private string m_lastName;
+ private Vector3 m_startPos;
+
+ /*
+ // Throw away duplicate or insignificant updates
+ if (!m_bodyRot.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) ||
+ !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) ||
+ !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE))
+ * */
+
+ public RegionSyncAvatar(Scene scene, UUID agentID, string first, string last, Vector3 startPos)
+ {
+ m_scene = scene;
+ m_agentID = agentID;
+ m_firstName = first;
+ m_lastName = last;
+ m_startPos = startPos;
+
+ //m_scene.EventManager.OnFrame += Update;
+ }
+
+ public bool AgentUpdate(AgentUpdateArgs arg)
+ {
+ UpdateAgent handlerAgentUpdate = OnAgentUpdate;
+ if (handlerAgentUpdate != null)
+ {
+ OnAgentUpdate(this, arg);
+ handlerAgentUpdate = null;
+ return true;
+ }
+ handlerAgentUpdate = null;
+ return false;
+ }
+
+ public virtual Vector3 StartPos
+ {
+ get { return m_startPos; }
+ set { }
+ }
+
+ public virtual UUID AgentId
+ {
+ get { return m_agentID; }
+ }
+
+ public UUID SessionId
+ {
+ get { return UUID.Zero; }
+ }
+
+ public UUID SecureSessionId
+ {
+ get { return UUID.Zero; }
+ }
+
+ public virtual string FirstName
+ {
+ get { return m_firstName; }
+ }
+
+ public virtual string LastName
+ {
+ get { return m_lastName; }
+ }
+
+ public virtual String Name
+ {
+ get { return FirstName + LastName; }
+ }
+
+ public bool IsActive
+ {
+ get { return true; }
+ set { }
+ }
+
+ public UUID ActiveGroupId
+ {
+ get { return UUID.Zero; }
+ }
+
+ public string ActiveGroupName
+ {
+ get { return String.Empty; }
+ }
+
+ public ulong ActiveGroupPowers
+ {
+ get { return 0; }
+ }
+
+ public bool IsGroupMember(UUID groupID)
+ {
+ return false;
+ }
+
+ public ulong GetGroupPowers(UUID groupID)
+ {
+ return 0;
+ }
+
+ public virtual int NextAnimationSequenceNumber
+ {
+ get { return 1; }
+ }
+
+ public IScene Scene
+ {
+ get { return m_scene; }
+ }
+
+ public bool SendLogoutPacketWhenClosing
+ {
+ set { }
+ }
+
+ public virtual void ActivateGesture(UUID assetId, UUID gestureId)
+ {
+ }
+
+ public virtual void SendWearables(AvatarWearable[] wearables, int serial)
+ {
+ }
+
+ public virtual void SendAppearance(UUID agentID, byte[] visualParams, byte[] textureEntry)
+ {
+ }
+
+ public virtual void Kick(string message)
+ {
+ }
+
+ public virtual void SendStartPingCheck(byte seq)
+ {
+ }
+
+ public virtual void SendAvatarPickerReply(AvatarPickerReplyAgentDataArgs AgentData, List Data)
+ {
+ }
+
+ public virtual void SendAgentDataUpdate(UUID agentid, UUID activegroupid, string firstname, string lastname, ulong grouppowers, string groupname, string grouptitle)
+ {
+
+ }
+
+ public virtual void SendKillObject(ulong regionHandle, uint localID)
+ {
+ }
+
+ public virtual void SetChildAgentThrottle(byte[] throttle)
+ {
+ }
+ public byte[] GetThrottlesPacked(float multiplier)
+ {
+ return new byte[0];
+ }
+
+
+ public virtual void SendAnimations(UUID[] animations, int[] seqs, UUID sourceAgentId, UUID[] objectIDs)
+ {
+ }
+
+ public virtual void SendChatMessage(string message, byte type, Vector3 fromPos, string fromName,
+ UUID fromAgentID, byte source, byte audible)
+ {
+ }
+
+ public virtual void SendChatMessage(byte[] message, byte type, Vector3 fromPos, string fromName,
+ UUID fromAgentID, byte source, byte audible)
+ {
+ }
+
+ public void SendInstantMessage(GridInstantMessage im)
+ {
+
+ }
+
+ public void SendGenericMessage(string method, List message)
+ {
+
+ }
+
+ public virtual void SendLayerData(float[] map)
+ {
+ }
+
+ public virtual void SendLayerData(int px, int py, float[] map)
+ {
+ }
+ public virtual void SendLayerData(int px, int py, float[] map, bool track)
+ {
+ }
+
+ public virtual void SendWindData(Vector2[] windSpeeds) { }
+
+ public virtual void SendCloudData(float[] cloudCover) { }
+
+ public virtual void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
+ {
+ }
+
+ public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint)
+ {
+ }
+
+ public virtual AgentCircuitData RequestClientInfo()
+ {
+ return new AgentCircuitData();
+ }
+
+ public virtual void CrossRegion(ulong newRegionHandle, Vector3 pos, Vector3 lookAt,
+ IPEndPoint newRegionExternalEndPoint, string capsURL)
+ {
+ }
+
+ public virtual void SendMapBlock(List mapBlocks, uint flag)
+ {
+ }
+
+ public virtual void SendLocalTeleport(Vector3 position, Vector3 lookAt, uint flags)
+ {
+ }
+
+ public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint,
+ uint locationID, uint flags, string capsURL)
+ {
+ }
+
+ public virtual void SendTeleportFailed(string reason)
+ {
+ }
+
+ public virtual void SendTeleportLocationStart()
+ {
+ }
+
+ public virtual void SendMoneyBalance(UUID transaction, bool success, byte[] description, int balance)
+ {
+ }
+
+ public virtual void SendPayPrice(UUID objectID, int[] payPrice)
+ {
+ }
+
+ public virtual void SendAvatarData(SendAvatarData data)
+ {
+ }
+
+ public virtual void SendAvatarTerseUpdate(SendAvatarTerseData data)
+ {
+ }
+
+ public virtual void SendCoarseLocationUpdate(List users, List CoarseLocations)
+ {
+ }
+
+ public virtual void AttachObject(uint localID, Quaternion rotation, byte attachPoint, UUID ownerID)
+ {
+ }
+
+ public virtual void SendDialog(string objectname, UUID objectID, string ownerFirstName, string ownerLastName, string msg, UUID textureID, int ch, string[] buttonlabels)
+ {
+ }
+
+ public virtual void SendPrimitiveToClient(SendPrimitiveData data)
+ {
+ }
+
+ public virtual void SendPrimTerseUpdate(SendPrimitiveTerseData data)
+ {
+ }
+
+ public virtual void ReprioritizeUpdates(StateUpdateTypes type, UpdatePriorityHandler handler)
+ {
+ }
+
+ public void FlushPrimUpdates()
+ {
+ }
+
+ public virtual void SendInventoryFolderDetails(UUID ownerID, UUID folderID,
+ List items,
+ List folders,
+ int version,
+ bool fetchFolders,
+ bool fetchItems)
+ {
+ }
+
+ public virtual void SendInventoryItemDetails(UUID ownerID, InventoryItemBase item)
+ {
+ }
+
+ public virtual void SendInventoryItemCreateUpdate(InventoryItemBase Item, uint callbackID)
+ {
+ }
+
+ public virtual void SendRemoveInventoryItem(UUID itemID)
+ {
+ }
+
+ public virtual void SendBulkUpdateInventory(InventoryNodeBase node)
+ {
+ }
+
+ public UUID GetDefaultAnimation(string name)
+ {
+ return UUID.Zero;
+ }
+
+ public void SendTakeControls(int controls, bool passToAgent, bool TakeControls)
+ {
+ }
+
+ public virtual void SendTaskInventory(UUID taskID, short serial, byte[] fileName)
+ {
+ }
+
+ public virtual void SendXferPacket(ulong xferID, uint packet, byte[] data)
+ {
+ }
+
+ public virtual void SendEconomyData(float EnergyEfficiency, int ObjectCapacity, int ObjectCount, int PriceEnergyUnit,
+ int PriceGroupCreate, int PriceObjectClaim, float PriceObjectRent, float PriceObjectScaleFactor,
+ int PriceParcelClaim, float PriceParcelClaimFactor, int PriceParcelRent, int PricePublicObjectDecay,
+ int PricePublicObjectDelete, int PriceRentLight, int PriceUpload, int TeleportMinPrice, float TeleportPriceExponent)
+ {
+
+ }
+ public virtual void SendNameReply(UUID profileId, string firstname, string lastname)
+ {
+ }
+
+ public virtual void SendPreLoadSound(UUID objectID, UUID ownerID, UUID soundID)
+ {
+ }
+
+ public virtual void SendPlayAttachedSound(UUID soundID, UUID objectID, UUID ownerID, float gain,
+ byte flags)
+ {
+ }
+
+ public void SendTriggeredSound(UUID soundID, UUID ownerID, UUID objectID, UUID parentID, ulong handle, Vector3 position, float gain)
+ {
+ }
+
+ public void SendAttachedSoundGainChange(UUID objectID, float gain)
+ {
+
+ }
+
+ public void SendAlertMessage(string message)
+ {
+ }
+
+ public void SendAgentAlertMessage(string message, bool modal)
+ {
+ }
+
+ public void SendSystemAlertMessage(string message)
+ {
+ }
+
+ public void SendLoadURL(string objectname, UUID objectID, UUID ownerID, bool groupOwned, string message,
+ string url)
+ {
+ }
+
+ public virtual void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args)
+ {
+ if (OnRegionHandShakeReply != null)
+ {
+ OnRegionHandShakeReply(this);
+ }
+
+ if (OnCompleteMovementToRegion != null)
+ {
+ OnCompleteMovementToRegion(this);
+ }
+ }
+ public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID)
+ {
+ }
+
+ public void SendConfirmXfer(ulong xferID, uint PacketID)
+ {
+ }
+
+ public void SendXferRequest(ulong XferID, short AssetType, UUID vFileID, byte FilePath, byte[] FileName)
+ {
+ }
+
+ public void SendInitiateDownload(string simFileName, string clientFileName)
+ {
+ }
+
+ public void SendImageFirstPart(ushort numParts, UUID ImageUUID, uint ImageSize, byte[] ImageData, byte imageCodec)
+ {
+ }
+
+ public void SendImageNextPart(ushort partNumber, UUID imageUuid, byte[] imageData)
+ {
+ }
+
+ public void SendImageNotFound(UUID imageid)
+ {
+ }
+
+ public void SendShutdownConnectionNotice()
+ {
+ }
+
+ public void SendSimStats(SimStats stats)
+ {
+ }
+
+ public void SendObjectPropertiesFamilyData(uint RequestFlags, UUID ObjectUUID, UUID OwnerID, UUID GroupID,
+ uint BaseMask, uint OwnerMask, uint GroupMask, uint EveryoneMask,
+ uint NextOwnerMask, int OwnershipCost, byte SaleType,int SalePrice, uint Category,
+ UUID LastOwnerID, string ObjectName, string Description)
+ {
+ }
+
+ public void SendObjectPropertiesReply(UUID ItemID, ulong CreationDate, UUID CreatorUUID, UUID FolderUUID, UUID FromTaskUUID,
+ UUID GroupUUID, short InventorySerial, UUID LastOwnerUUID, UUID ObjectUUID,
+ UUID OwnerUUID, string TouchTitle, byte[] TextureID, string SitTitle, string ItemName,
+ string ItemDescription, uint OwnerMask, uint NextOwnerMask, uint GroupMask, uint EveryoneMask,
+ uint BaseMask, byte saleType, int salePrice)
+ {
+ }
+
+ public void SendAgentOffline(UUID[] agentIDs)
+ {
+
+ }
+
+ public void SendAgentOnline(UUID[] agentIDs)
+ {
+
+ }
+
+ public void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot,
+ Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook)
+ {
+ }
+
+ public void SendAdminResponse(UUID Token, uint AdminLevel)
+ {
+
+ }
+
+ public void SendGroupMembership(GroupMembershipData[] GroupMembership)
+ {
+
+ }
+
+ private void Update()
+ {
+ frame++;
+ if (frame > 20)
+ {
+ frame = 0;
+ if (OnAgentUpdate != null)
+ {
+ AgentUpdateArgs pack = new AgentUpdateArgs();
+ pack.ControlFlags = movementFlag;
+ pack.BodyRotation = bodyDirection;
+
+ OnAgentUpdate(this, pack);
+ }
+ if (flyState == 0)
+ {
+ movementFlag = (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY |
+ (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG;
+ flyState = 1;
+ }
+ else if (flyState == 1)
+ {
+ movementFlag = (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY |
+ (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS;
+ flyState = 2;
+ }
+ else
+ {
+ movementFlag = (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
+ flyState = 0;
+ }
+
+ if (count >= 10)
+ {
+ if (OnChatFromClient != null)
+ {
+ OSChatMessage args = new OSChatMessage();
+ args.Message = "Hey You! Get out of my Home. This is my Region";
+ args.Channel = 0;
+ args.From = FirstName + " " + LastName;
+ args.Scene = m_scene;
+ args.Position = new Vector3(128, 128, 26);
+ args.Sender = this;
+ args.Type = ChatTypeEnum.Shout;
+
+ OnChatFromClient(this, args);
+ }
+ count = -1;
+ }
+
+ count++;
+ }
+ }
+
+ public bool AddMoney(int debit)
+ {
+ return false;
+ }
+
+ public void SendSunPos(Vector3 sunPos, Vector3 sunVel, ulong time, uint dlen, uint ylen, float phase)
+ {
+ }
+
+ public void SendViewerEffect(ViewerEffectPacket.EffectBlock[] effectBlocks)
+ {
+ }
+
+ public void SendViewerTime(int phase)
+ {
+ }
+
+ public void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, Byte[] charterMember,
+ string flAbout, uint flags, UUID flImageID, UUID imageID, string profileURL,
+ UUID partnerID)
+ {
+ }
+
+ public void SetDebugPacketLevel(int newDebug)
+ {
+ }
+
+ public void InPacket(object NewPack)
+ {
+ }
+
+ public void ProcessInPacket(Packet NewPack)
+ {
+ }
+
+ public void Close()
+ {
+ }
+
+ public void Start()
+ {
+ }
+
+ public void Stop()
+ {
+ }
+
+ private uint m_circuitCode;
+
+ public uint CircuitCode
+ {
+ get { return m_circuitCode; }
+ set { m_circuitCode = value; }
+ }
+
+ public IPEndPoint RemoteEndPoint
+ {
+ get { return new IPEndPoint(IPAddress.Loopback, (ushort)m_circuitCode); }
+ }
+
+ public void SendBlueBoxMessage(UUID FromAvatarID, String FromAvatarName, String Message)
+ {
+
+ }
+ public void SendLogoutPacket()
+ {
+ }
+
+ public void Terminate()
+ {
+ }
+
+ public EndPoint GetClientEP()
+ {
+ return null;
+ }
+
+ public ClientInfo GetClientInfo()
+ {
+ return null;
+ }
+
+ public void SetClientInfo(ClientInfo info)
+ {
+ }
+
+ public void SendScriptQuestion(UUID objectID, string taskName, string ownerName, UUID itemID, int question)
+ {
+ }
+ public void SendHealth(float health)
+ {
+ }
+
+ public void SendEstateManagersList(UUID invoice, UUID[] EstateManagers, uint estateID)
+ {
+ }
+
+ public void SendBannedUserList(UUID invoice, EstateBan[] banlist, uint estateID)
+ {
+ }
+
+ public void SendRegionInfoToEstateMenu(RegionInfoForEstateMenuArgs args)
+ {
+ }
+
+ public void SendEstateCovenantInformation(UUID covenant)
+ {
+ }
+
+ public void SendDetailedEstateData(UUID invoice, string estateName, uint estateID, uint parentEstate, uint estateFlags, uint sunPosition, UUID covenant, string abuseEmail, UUID estateOwner)
+ {
+ }
+
+ public void SendLandProperties(int sequence_id, bool snap_selection, int request_result, LandData landData, float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags)
+ {
+ }
+
+ public void SendLandAccessListData(List avatars, uint accessFlag, int localLandID)
+ {
+ }
+
+ public void SendForceClientSelectObjects(List objectIDs)
+ {
+ }
+
+ public void SendLandObjectOwners(LandData land, List groups, Dictionary ownersAndCount)
+ {
+ }
+
+ public void SendCameraConstraint(Vector4 ConstraintPlane)
+ {
+
+ }
+
+ public void SendLandParcelOverlay(byte[] data, int sequence_id)
+ {
+ }
+
+ public void SendParcelMediaCommand(uint flags, ParcelMediaCommandEnum command, float time)
+ {
+ }
+
+ public void SendParcelMediaUpdate(string mediaUrl, UUID mediaTextureID, byte autoScale, string mediaType,
+ string mediaDesc, int mediaWidth, int mediaHeight, byte mediaLoop)
+ {
+ }
+
+ public void SendGroupNameReply(UUID groupLLUID, string GroupName)
+ {
+ }
+
+ public void SendLandStatReply(uint reportType, uint requestFlags, uint resultCount, LandStatReportItem[] lsrpia)
+ {
+ }
+
+ public void SendScriptRunningReply(UUID objectID, UUID itemID, bool running)
+ {
+ }
+
+ public void SendAsset(AssetRequestToClient req)
+ {
+ }
+
+ public void SendTexture(AssetBase TextureAsset)
+ {
+
+ }
+
+ public void SendSetFollowCamProperties (UUID objectID, SortedDictionary parameters)
+ {
+ }
+
+ public void SendClearFollowCamProperties (UUID objectID)
+ {
+ }
+
+ public void SendRegionHandle (UUID regoinID, ulong handle)
+ {
+ }
+
+ public void SendParcelInfo (RegionInfo info, LandData land, UUID parcelID, uint x, uint y)
+ {
+ }
+
+ public void SetClientOption(string option, string value)
+ {
+ }
+
+ public string GetClientOption(string option)
+ {
+ return string.Empty;
+ }
+
+ public void SendScriptTeleportRequest(string objName, string simName, Vector3 pos, Vector3 lookAt)
+ {
+ }
+
+ public void SendDirPlacesReply(UUID queryID, DirPlacesReplyData[] data)
+ {
+ }
+
+ public void SendDirPeopleReply(UUID queryID, DirPeopleReplyData[] data)
+ {
+ }
+
+ public void SendDirEventsReply(UUID queryID, DirEventsReplyData[] data)
+ {
+ }
+
+ public void SendDirGroupsReply(UUID queryID, DirGroupsReplyData[] data)
+ {
+ }
+
+ public void SendDirClassifiedReply(UUID queryID, DirClassifiedReplyData[] data)
+ {
+ }
+
+ public void SendDirLandReply(UUID queryID, DirLandReplyData[] data)
+ {
+ }
+
+ public void SendDirPopularReply(UUID queryID, DirPopularReplyData[] data)
+ {
+ }
+
+ public void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags)
+ {
+ }
+
+ public void KillEndDone()
+ {
+ }
+
+ public void SendEventInfoReply (EventData info)
+ {
+ }
+
+ public void SendOfferCallingCard (UUID destID, UUID transactionID)
+ {
+ }
+
+ public void SendAcceptCallingCard (UUID transactionID)
+ {
+ }
+
+ public void SendDeclineCallingCard (UUID transactionID)
+ {
+ }
+
+ public void SendAvatarGroupsReply(UUID avatarID, GroupMembershipData[] data)
+ {
+ }
+
+ public void SendJoinGroupReply(UUID groupID, bool success)
+ {
+ }
+
+ public void SendEjectGroupMemberReply(UUID agentID, UUID groupID, bool succss)
+ {
+ }
+
+ public void SendLeaveGroupReply(UUID groupID, bool success)
+ {
+ }
+
+ public void SendTerminateFriend(UUID exFriendID)
+ {
+ }
+
+ #region IClientAPI Members
+
+
+ public bool AddGenericPacketHandler(string MethodName, GenericMessage handler)
+ {
+ return true;
+ }
+
+ public void SendAvatarClassifiedReply(UUID targetID, UUID[] classifiedID, string[] name)
+ {
+ }
+
+ public void SendClassifiedInfoReply(UUID classifiedID, UUID creatorID, uint creationDate, uint expirationDate, uint category, string name, string description, UUID parcelID, uint parentEstate, UUID snapshotID, string simName, Vector3 globalPos, string parcelName, byte classifiedFlags, int price)
+ {
+ }
+
+ public void SendAgentDropGroup(UUID groupID)
+ {
+ }
+
+ public void SendAvatarNotesReply(UUID targetID, string text)
+ {
+ }
+
+ public void SendAvatarPicksReply(UUID targetID, Dictionary picks)
+ {
+ }
+
+ public void SendAvatarClassifiedReply(UUID targetID, Dictionary classifieds)
+ {
+ }
+
+ public void SendParcelDwellReply(int localID, UUID parcelID, float dwell)
+ {
+ }
+
+ public void SendUserInfoReply(bool imViaEmail, bool visible, string email)
+ {
+ }
+
+ public void SendCreateGroupReply(UUID groupID, bool success, string message)
+ {
+ }
+
+ public void RefreshGroupMembership()
+ {
+ }
+
+ public void SendUseCachedMuteList()
+ {
+ }
+
+ public void SendMuteListUpdate(string filename)
+ {
+ }
+
+ public void SendPickInfoReply(UUID pickID,UUID creatorID, bool topPick, UUID parcelID, string name, string desc, UUID snapshotID, string user, string originalName, string simName, Vector3 posGlobal, int sortOrder, bool enabled)
+ {
+ }
+ #endregion
+
+ public void SendRebakeAvatarTextures(UUID textureID)
+ {
+ }
+
+ public bool IsLoggingOut
+ {
+ get { return false; }
+ set { }
+ }
+ public void SendAvatarInterestsReply(UUID avatarID, uint wantMask, string wantText, uint skillsMask, string skillsText, string languages)
+ {
+ throw new System.NotImplementedException();
+ }
+
+ public void SendGroupAccountingDetails(IClientAPI sender, UUID groupID, UUID transactionID, UUID sessionID, int amt)
+ {
+ throw new System.NotImplementedException();
+ }
+
+ public void SendGroupAccountingSummary(IClientAPI sender, UUID groupID, uint moneyAmt, int totalTier, int usedTier)
+ {
+ throw new System.NotImplementedException();
+ }
+
+ public void SendGroupTransactionsSummaryDetails(IClientAPI sender, UUID groupID, UUID transactionID, UUID sessionID, int amt)
+ {
+ throw new System.NotImplementedException();
+ }
+
+ public void SendGroupVoteHistory(UUID groupID, UUID transactionID, GroupVoteHistory[] Votes)
+ {
+ throw new System.NotImplementedException();
+ }
+
+ public void SendGroupActiveProposals(UUID groupID, UUID transactionID, GroupActiveProposals[] Proposals)
+ {
+ throw new System.NotImplementedException();
+ }
+
+ public void SendChangeUserRights(UUID agentID, UUID friendID, int rights)
+ {
+ throw new System.NotImplementedException();
+ }
+
+ public void SendTextBoxRequest(string message, int chatChannel, string objectname, string ownerFirstName, string ownerLastName, UUID objectId)
+ {
+ throw new System.NotImplementedException();
+ }
+
+ public void SendEstateList(UUID invoice, int code, UUID[] Data, uint estateID)
+ {
+ throw new System.NotImplementedException();
+ }
+
+ }
+}
diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs
new file mode 100644
index 0000000000..f9e6b92c61
--- /dev/null
+++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs
@@ -0,0 +1,374 @@
+using System;
+using System.IO;
+using System.Net;
+using System.Net.Sockets;
+using System.Text;
+using System.Collections.Generic;
+using System.Threading;
+using OpenMetaverse;
+using OpenMetaverse.StructuredData;
+using OpenSim.Framework;
+using OpenSim.Framework.Client;
+using OpenSim.Region.Framework.Scenes;
+using OpenSim.Region.Framework.Scenes.Serialization;
+using OpenSim.Region.Framework.Interfaces;
+using OpenSim.Region.Framework.Scenes.Types;
+using log4net;
+
+namespace OpenSim.Region.Examples.RegionSyncModule
+{
+ // The RegionSyncClient has a receive thread to process messages from the RegionSyncServer.
+ public class RegionSyncClient
+ {
+ #region RegionSyncClient members
+
+ // Set the addr and port of RegionSyncServer
+ private IPAddress m_addr;
+ private Int32 m_port;
+
+ // A reference to the local scene
+ private Scene m_scene;
+
+ // The logfile
+ private ILog m_log;
+
+ // The listener and the thread which listens for connections from client managers
+ private Thread m_rcvLoop;
+
+ // The client connection to the RegionSyncServer
+ private TcpClient m_client = new TcpClient();
+
+ // The queue of incoming messages which need handling
+ //private Queue m_inQ = new Queue();
+ #endregion
+
+ // Constructor
+ public RegionSyncClient(Scene scene, string addr, int port)
+ {
+ m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
+ m_log.Warn("[REGION SYNC CLIENT] Constructed");
+ m_scene = scene;
+ m_addr = IPAddress.Parse(addr);
+ m_port = port;
+ }
+
+ // Start the RegionSyncClient
+ public void Start()
+ {
+ try
+ {
+ m_client.Connect(m_addr, m_port);
+ }
+ catch (Exception e)
+ {
+ m_log.WarnFormat("[REGION SYNC CLIENT] [Start] Could not connect to RegionSyncServer at {0}:{1}", m_addr, m_port);
+ m_log.Warn(e.Message);
+ }
+
+ m_log.WarnFormat("[REGION SYNC CLIENT] Connected to RegionSyncServer at {0}:{1}", m_addr, m_port);
+
+ m_rcvLoop = new Thread(new ThreadStart(ReceiveLoop));
+ m_rcvLoop.Name = "RegionSyncClient ReceiveLoop";
+ m_log.WarnFormat("[REGION SYNC CLIENT] Starting {0} thread", m_rcvLoop.Name);
+ m_rcvLoop.Start();
+ m_log.Warn("[REGION SYNC CLIENT] Started");
+ DoInitialSync();
+ }
+
+ // Disconnect from the RegionSyncServer and close the RegionSyncClient
+ public void Stop()
+ {
+ m_rcvLoop.Abort();
+ ShutdownClient();
+ }
+
+ private void ShutdownClient()
+ {
+ m_log.WarnFormat("[REGION SYNC CLIENT] Disconnected from RegionSyncServer. Shutting down.");
+ m_scene.ForEachClient(delegate(IClientAPI client) { client.OnAgentUpdateRaw -= HandleAgentUpdateRaw; });
+ m_client.Client.Close();
+ m_client.Close();
+ }
+
+ // Listen for messages from a RegionSyncClient
+ // *** This is the main thread loop for each connected client
+ private void ReceiveLoop()
+ {
+ m_log.WarnFormat("[REGION SYNC CLIENT] Thread running: {0}", m_rcvLoop.Name);
+ while (true && m_client.Connected)
+ {
+ RegionSyncMessage msg;
+ // Try to get the message from the network stream
+ try
+ {
+ msg = new RegionSyncMessage(m_client.GetStream());
+ //m_log.WarnFormat("[REGION SYNC CLIENT] Received: {0}", msg.ToString());
+ }
+ // If there is a problem reading from the client, shut 'er down.
+ catch
+ {
+ ShutdownClient();
+ return;
+ }
+ // Try handling the message
+ try
+ {
+ HandleMessage(msg);
+ }
+ catch (Exception e)
+ {
+ m_log.WarnFormat("[REGION SYNC CLIENT] Encountered an exception: {0}", e.Message);
+ }
+ }
+ }
+
+ #region Send
+ // Send a message to a single connected RegionSyncClient
+ private void Send(string msg)
+ {
+ byte[] bmsg = System.Text.Encoding.ASCII.GetBytes(msg + System.Environment.NewLine);
+ Send(bmsg);
+ }
+
+ private void Send(RegionSyncMessage msg)
+ {
+ Send(msg.ToBytes());
+ //m_log.WarnFormat("[REGION SYNC CLIENT] Sent {0}", msg.ToString());
+ }
+
+ private void Send(byte[] data)
+ {
+ if (m_client.Connected)
+ {
+ try
+ {
+ m_client.GetStream().Write(data, 0, data.Length);
+ }
+ // If there is a problem reading from the client, shut 'er down.
+ // *** Still need to alert the module that it's no longer connected!
+ catch
+ {
+ ShutdownClient();
+ }
+ }
+ }
+ #endregion
+
+ // Handle an incoming message
+ // TODO: This should not be synchronous with the receive!
+ // Instead, handle messages from the incoming Queue
+ private bool HandleMessage(RegionSyncMessage msg)
+ {
+ switch (msg.Type)
+ {
+ case RegionSyncMessage.MsgType.Terrain:
+ {
+ m_scene.Heightmap.LoadFromXmlString(Encoding.ASCII.GetString(msg.Data));
+ return HandlerSuccess(msg, "Syncrhonized terrain");
+ }
+ case RegionSyncMessage.MsgType.RegionArchive:
+ {
+ IRegionArchiverModule archiver = m_scene.RequestModuleInterface();
+ if (archiver == null)
+ {
+ return HandlerFailure(msg, "Could not retrieve archiver module.");
+ }
+ MemoryStream ms = new MemoryStream(msg.Data);
+ archiver.DearchiveRegion(ms);
+ return HandlerSuccess(msg,"Synchronized region");
+ }
+ case RegionSyncMessage.MsgType.AddObject:
+ case RegionSyncMessage.MsgType.UpdateObject:
+ {
+ SceneObjectGroup sog = SceneObjectSerializer.FromXml2Format(Encoding.ASCII.GetString(msg.Data));
+ if(sog.IsDeleted)
+ return HandlerFailure(msg, String.Format("Ignoring update on deleted LocalId {0}.", sog.LocalId.ToString()));
+ if (m_scene.AddNewSceneObject(sog, true))
+ {
+ sog.ScheduleGroupForFullUpdate();
+ return HandlerSuccess(msg, String.Format("LocalId {0} added or updated.", sog.LocalId.ToString()));
+ }
+ return HandlerFailure(msg, String.Format("Could not add or update LocalId {0}.", sog.LocalId.ToString()));
+ }
+ case RegionSyncMessage.MsgType.UpdateAvatarTerse:
+ {
+
+ OSDMap data = OSDParser.DeserializeJson(Encoding.ASCII.GetString(msg.Data)) as OSDMap;
+ if( data != null )
+ {
+ UUID agentID = data["id"].AsUUID();
+ Vector3 pos = data["pos"].AsVector3();
+ Vector3 vel = data["vel"].AsVector3();
+ Quaternion rot = data["rot"].AsQuaternion();
+
+ // We get the UUID of the object to be deleted, find it in the scene
+ if (agentID != UUID.Zero)
+ {
+ ScenePresence presence = m_scene.GetScenePresence(agentID);
+ if (presence != null)
+ {
+ presence.AbsolutePosition = pos;
+ presence.Velocity = vel;
+ presence.Rotation = rot;
+ presence.SendTerseUpdateToAllClients();
+ return HandlerSuccess(msg, String.Format("agentID {0} updated", agentID.ToString()));
+ }
+ }
+ return HandlerFailure(msg, String.Format("agentID {0} not found.", agentID.ToString()));
+ }
+ return HandlerFailure(msg, "Could not parse AgentUpdate parameters");
+ }
+ // return HandlerSuccess(msg, "Updated avatar");
+ /*
+ case RegionSyncMessage.MsgType.SetObjectPosition: Attributes!
+ {
+ if (part.ParentGroup == null)
+ {
+ part.UpdateOffSet(new Vector3((float)real_vec.x, (float)real_vec.y, (float)real_vec.z));
+ }
+ else if (part.ParentGroup.RootPart == part)
+ {
+ part.parent.UpdateGroupPosition(new Vector3((float)real_vec.x, (float)real_vec.y, (float)real_vec.z));
+ }
+ else
+ {
+ part.OffsetPosition = new Vector3((float)targetPos.x, (float)targetPos.y, (float)targetPos.z);
+ SceneObjectGroup parent = part.ParentGroup;
+ parent.HasGroupChanged = true;
+ parent.ScheduleGroupForTerseUpdate();
+ }
+ }
+ * */
+ case RegionSyncMessage.MsgType.RemoveObject:
+ {
+ OSDMap data = OSDParser.DeserializeJson(Encoding.ASCII.GetString(msg.Data)) as OSDMap;
+ if( data != null )
+ {
+ ulong regionHandle = data["regionHandle"].AsULong();
+ uint localID = data["localID"].AsUInteger();
+
+ // We get the UUID of the object to be deleted, find it in the scene
+ if (regionHandle != 0 && localID != 0 )
+ {
+ if (regionHandle == m_scene.RegionInfo.RegionHandle)
+ {
+ SceneObjectGroup sog = m_scene.SceneGraph.GetGroupByPrim(localID);
+ if (sog != null)
+ {
+ m_scene.DeleteSceneObject(sog, false);
+ return HandlerSuccess(msg, String.Format("localID {0} deleted.", localID.ToString()));
+ }
+ }
+ return HandlerFailure(msg, String.Format("ignoring delete request for non-local regionHandle {0}.", regionHandle.ToString()));
+ }
+ return HandlerFailure(msg, String.Format("localID {0} not found.", localID.ToString()));
+ }
+ return HandlerFailure(msg, "Could not parse DeleteObject parameters");
+ }
+ /*
+ case RegionSyncMessage.MsgType.UpdateObject:
+ {
+ UUID uuid;
+ if (UUID.TryParse(Encoding.ASCII.GetString(msg.Data), out uuid))
+ {
+ // We get the UUID of the object to be updated, find it in the scene
+ SceneObjectGroup sog = m_scene.SceneGraph.GetGroupByPrim(uuid);
+ Vector3 v = new Vector3();
+ v.ToString();
+ if (sog != null)
+ {
+ //m_scene.DeleteSceneObject(sog, false);
+ return HandlerSuccess(msg, String.Format("UUID {0} updated.", uuid.ToString()));
+ }
+ else
+ {
+ return HandlerFailure(msg, String.Format("UUID {0} not found.", uuid.ToString()));
+ }
+ }
+ return HandlerFailure(msg, "Could not parse UUID");
+ }
+ * */
+ default:
+ {
+ m_log.WarnFormat("[REGION SYNC CLIENT] Unsupported message type");
+ return false;
+ }
+ }
+ }
+
+ private bool HandlerSuccess(RegionSyncMessage msg, string handlerMessage)
+ {
+ //m_log.WarnFormat("[REGION SYNC CLIENT] Handled {0}: {1}", msg.ToString(), handlerMessage);
+ return true;
+ }
+
+ private bool HandlerFailure(RegionSyncMessage msg, string handlerMessage)
+ {
+ //m_log.WarnFormat("[REGION SYNC SERVER] Unable to handle {0}: {1}", msg.ToString(), handlerMessage);
+ return false;
+ }
+
+ private void DoInitialSync()
+ {
+ m_scene.DeleteAllSceneObjects();
+ Send(new RegionSyncMessage(RegionSyncMessage.MsgType.GetTerrain));
+ Send(new RegionSyncMessage(RegionSyncMessage.MsgType.GetObjects));
+ //Send(new RegionSyncMessage(RegionSyncMessage.MsgType.GetRegionArchive));
+ // Register for events which will be forwarded to authoritative scene
+ m_scene.EventManager.OnNewClient += EventManager_OnNewClient;
+ }
+
+ public string GetServerAddressAndPort()
+ {
+ return m_addr.ToString() + ":" + m_port.ToString();
+ }
+
+
+ #region Event Handlers
+
+ public void EventManager_OnNewClient(IClientAPI client)
+ {
+ // Let the auth sim know that a new agent has connected
+ OSDMap data = new OSDMap(1);
+ data["agentID"] = OSD.FromUUID(client.AgentId);
+ data["first"] = OSD.FromString(client.FirstName);
+ data["last"] = OSD.FromString(client.LastName);
+ data["startPos"] = OSD.FromVector3(client.StartPos);
+ Send(new RegionSyncMessage(RegionSyncMessage.MsgType.AgentAdd, OSDParser.SerializeJsonString(data)));
+
+ // Register for interesting client events which will be forwarded to auth sim
+ // These are the raw packet data blocks from the client, intercepted and sent up to the sim
+ client.OnAgentUpdateRaw += HandleAgentUpdateRaw;
+ client.OnChatFromClientRaw += HandleChatFromClientRaw;
+ }
+
+ ///
+ /// This is the event handler for client movement. If a client is moving, this event is triggering.
+ ///
+ public void HandleAgentUpdateRaw(object sender, byte[] agentData)
+ {
+ Send(new RegionSyncMessage(RegionSyncMessage.MsgType.AgentUpdate, agentData));
+ }
+
+ public void HandleChatFromClientRaw(object sender, byte[] chatData)
+ {
+ Send(new RegionSyncMessage(RegionSyncMessage.MsgType.ChatFromClient, chatData));
+ }
+
+ #endregion
+ /*
+ // Should be part of the RegionSyncClient
+ public string ReceiveMsg()
+ {
+ lock (m_outQ)
+ {
+ if (m_outQ.Count > 0)
+ {
+ return m_outQ.Dequeue();
+ }
+ }
+ return null;
+ }
+ * */
+ }
+}
diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClientModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClientModule.cs
new file mode 100644
index 0000000000..ab51b9377a
--- /dev/null
+++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClientModule.cs
@@ -0,0 +1,222 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSim Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using Nini.Config;
+using OpenMetaverse;
+using OpenSim.Framework;
+using OpenSim.Framework.Client;
+using OpenSim.Region.CoreModules.Framework.InterfaceCommander;
+using OpenSim.Region.Framework.Interfaces;
+using OpenSim.Region.Framework.Scenes;
+using log4net;
+using System.Net;
+using System.Net.Sockets;
+
+namespace OpenSim.Region.Examples.RegionSyncModule
+{
+ public class RegionSyncClientModule : IRegionModule, IRegionSyncClientModule, ICommandableModule
+ {
+ #region IRegionModule Members
+
+ public void Initialise(Scene scene, IConfigSource config)
+ {
+ m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
+ IConfig syncConfig = config.Configs["RegionSyncModule"];
+ if (syncConfig == null || syncConfig.GetString("Mode", "client").ToLower() != "client")
+ {
+ m_active = false;
+ m_log.Warn("[REGION SYNC CLIENT MODULE] Not in client mode. Shutting down.");
+ return;
+ }
+ m_serveraddr = syncConfig.GetString("ServerIPAddress", "127.0.0.1");
+ m_serverport = syncConfig.GetInt("ServerPort", 13000);
+ m_scene = scene;
+ m_scene.RegisterModuleInterface(this);
+
+ // Setup the command line interface
+ m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
+ InstallInterfaces();
+
+ m_log.Warn("[REGION SYNC CLIENT MODULE] Initialised");
+ }
+
+ public void PostInitialise()
+ {
+ if (!m_active)
+ return;
+
+ m_log.Warn("[REGION SYNC CLIENT MODULE] Post-Initialised");
+ }
+
+ public void Close()
+ {
+ m_scene = null;
+ }
+
+ public string Name
+ {
+ get { return "RegionSyncModule"; }
+ }
+
+ public bool IsSharedModule
+ {
+ get { return false; }
+ }
+ #endregion
+
+ #region ICommandableModule Members
+ private readonly Commander m_commander = new Commander("sync");
+ public ICommander CommandInterface
+ {
+ get { return m_commander; }
+ }
+ #endregion
+
+ #region IRegionSyncClientModule members
+ public bool Active
+ {
+ get { return m_active; }
+ }
+
+ public bool Synced
+ {
+ get
+ {
+ lock(m_client_lock)
+ {
+ return (m_client != null);
+ }
+ }
+ }
+ #endregion
+
+ #region RegionSyncClientModule members
+ private bool m_active = true;
+ private string m_serveraddr;
+ private int m_serverport;
+ private Scene m_scene;
+ private ILog m_log;
+ private Object m_client_lock = new Object();
+ private RegionSyncClient m_client = null;
+ #endregion
+
+ #region Event Handlers
+ #endregion
+
+ private void DebugSceneStats()
+ {
+ return;
+ /*
+ List avatars = m_scene.GetAvatars();
+ List entities = m_scene.GetEntities();
+ m_log.WarnFormat("There are {0} avatars and {1} entities in the scene", avatars.Count, entities.Count);
+ */
+ }
+
+ #region Console Command Interface
+ private void InstallInterfaces()
+ {
+ Command cmdSyncStart = new Command("start", CommandIntentions.COMMAND_HAZARDOUS, SyncStart, "Begins synchronization with RegionSyncServer.");
+ //cmdSyncStart.AddArgument("server_address", "The IP address of the server to synchronize with", "String");
+ //cmdSyncStart.AddArgument("server_port", "The port of the server to synchronize with", "Integer");
+
+ Command cmdSyncStop = new Command("stop", CommandIntentions.COMMAND_HAZARDOUS, SyncStop, "Stops synchronization with RegionSyncServer.");
+ //cmdSyncStop.AddArgument("server_address", "The IP address of the server to synchronize with", "String");
+ //cmdSyncStop.AddArgument("server_port", "The port of the server to synchronize with", "Integer");
+
+ m_commander.RegisterCommand("start", cmdSyncStart);
+ m_commander.RegisterCommand("stop", cmdSyncStop);
+
+ lock (m_scene)
+ {
+ // Add this to our scene so scripts can call these functions
+ m_scene.RegisterModuleCommander(m_commander);
+ }
+ }
+
+
+ ///
+ /// Processes commandline input. Do not call directly.
+ ///
+ /// Commandline arguments
+ private void EventManager_OnPluginConsole(string[] args)
+ {
+ if (args[0] == "sync")
+ {
+ if (args.Length == 1)
+ {
+ m_commander.ProcessConsoleCommand("help", new string[0]);
+ return;
+ }
+
+ string[] tmpArgs = new string[args.Length - 2];
+ int i;
+ for (i = 2; i < args.Length; i++)
+ tmpArgs[i - 2] = args[i];
+
+ m_commander.ProcessConsoleCommand(args[1], tmpArgs);
+ }
+ }
+
+ private void SyncStart(Object[] args)
+ {
+ lock (m_client_lock)
+ {
+ if (m_client != null)
+ {
+ m_log.WarnFormat("[REGION SYNC CLIENT MODULE] Already synchronizing to {0}", m_client.GetServerAddressAndPort());
+ return;
+ }
+ m_log.Warn("[REGION SYNC CLIENT MODULE] Starting synchronization");
+ m_log.Warn("[REGION SYNC CLIENT MODULE] Starting RegionSyncClient");
+
+ m_client = new RegionSyncClient(m_scene, m_serveraddr, m_serverport);
+ m_client.Start();
+ }
+ }
+
+ private void SyncStop(Object[] args)
+ {
+ lock(m_client_lock)
+ {
+ if (m_client == null)
+ {
+ m_log.WarnFormat("[REGION SYNC CLIENT MODULE] Already stopped");
+ return;
+ }
+ m_client.Stop();
+ m_client = null;
+ m_log.Warn("[REGION SYNC CLIENT MODULE] Stopping synchronization");
+ }
+ }
+ #endregion
+ }
+}
diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClientView.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClientView.cs
new file mode 100644
index 0000000000..3ad112a60e
--- /dev/null
+++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClientView.cs
@@ -0,0 +1,288 @@
+using System;
+using System.IO;
+using System.Net;
+using System.Net.Sockets;
+using System.Text;
+using System.Collections.Generic;
+using System.Threading;
+using OpenMetaverse;
+using OpenMetaverse.Packets;
+using OpenMetaverse.StructuredData;
+using OpenSim.Framework;
+using OpenSim.Region.Framework.Scenes;
+using OpenSim.Region.Framework.Scenes.Serialization;
+using OpenSim.Region.Framework.Interfaces;
+using log4net;
+
+namespace OpenSim.Region.Examples.RegionSyncModule
+{
+ // The RegionSyncClientView acts as a thread on the RegionSyncServer to handle incoming
+ // messages from RegionSyncClients.
+ public class RegionSyncClientView
+ {
+ #region RegionSyncClientView members
+ // The TcpClient this view uses to communicate with its RegionSyncClient
+ private TcpClient m_tcpclient;
+ // Set the addr and port for TcpListener
+ private IPAddress m_addr;
+ private Int32 m_port;
+ private int m_connection_number;
+ private Scene m_scene;
+
+ Dictionary m_syncedAvatars = new Dictionary();
+
+ // A queue for incoming and outgoing traffic
+ private Queue m_inQ = new Queue();
+ private Queue m_outQ = new Queue();
+
+ private ILog m_log;
+
+ private Thread m_receive_loop;
+
+ // The last time the entire region was sent to this RegionSyncClient
+ private long m_archive_time;
+
+ // A string of the format [REGION SYNC CLIENT VIEW #X] for use in log headers
+ private string LogHeader
+ {
+ get { return String.Format("[REGION SYNC CLIENT VIEW #{0}]", m_connection_number); }
+ }
+
+ // A string of the format "RegionSyncClientView #X" for use in describing the object itself
+ public string Description
+ {
+ get { return String.Format("RegionSyncClientView #{0}", m_connection_number); }
+ }
+
+ // Check if the client is connected
+ public bool Connected
+ { get { return m_tcpclient.Connected; } }
+ #endregion
+
+ // Constructor
+ public RegionSyncClientView(int num, Scene scene, TcpClient client)
+ {
+ m_connection_number = num;
+ m_scene = scene;
+ m_tcpclient = client;
+ m_addr = ((IPEndPoint)client.Client.RemoteEndPoint).Address;
+ m_port = ((IPEndPoint)client.Client.RemoteEndPoint).Port;
+
+ m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
+ m_log.WarnFormat("{0} Constructed", LogHeader);
+
+ // Create a thread for the receive loop
+ m_receive_loop = new Thread(new ThreadStart(delegate() { ReceiveLoop(); }));
+ m_receive_loop.Name = Description;
+ m_log.WarnFormat("{0} Started thread: {1}", LogHeader, m_receive_loop.Name);
+ m_receive_loop.Start();
+ }
+
+ // Stop the RegionSyncClientView, disconnecting the RegionSyncClient
+ public void Shutdown()
+ {
+ // Abort ReceiveLoop Thread, close Socket and TcpClient
+ m_receive_loop.Abort();
+ m_tcpclient.Client.Close();
+ m_tcpclient.Close();
+ }
+
+ // Listen for messages from a RegionSyncClient
+ // *** This is the main thread loop for each connected client
+ private void ReceiveLoop()
+ {
+ try
+ {
+ while (true)
+ {
+ RegionSyncMessage msg = GetMessage();
+ HandleMessage(msg);
+ }
+ }
+ catch (Exception e)
+ {
+ m_log.WarnFormat("{0} RegionSyncClient has disconnected.", LogHeader);
+ }
+ }
+
+ // Get a message from the RegionSyncClient
+ private RegionSyncMessage GetMessage()
+ {
+ // Get a RegionSyncMessager from the incoming stream
+ RegionSyncMessage msg = new RegionSyncMessage(m_tcpclient.GetStream());
+ m_log.WarnFormat("{0} Received {1}", LogHeader, msg.ToString());
+ return msg;
+ }
+
+ // Handle an incoming message
+ // *** Perhaps this should not be synchronous with the receive
+ // We could handle messages from an incoming Queue
+ private bool HandleMessage(RegionSyncMessage msg)
+ {
+ //string handlerMessage = "";
+ switch (msg.Type)
+ {
+ case RegionSyncMessage.MsgType.GetObjects:
+ {
+ List entities = m_scene.GetEntities();
+ foreach(EntityBase e in entities)
+ {
+ if (e is SceneObjectGroup)
+ {
+ string sogxml = SceneObjectSerializer.ToXml2Format((SceneObjectGroup)e);
+ Send(new RegionSyncMessage(RegionSyncMessage.MsgType.AddObject, sogxml));
+ }
+ }
+ return HandlerSuccess(msg, "Sent all scene objects");
+ }
+ case RegionSyncMessage.MsgType.GetTerrain:
+ {
+ Send(new RegionSyncMessage(RegionSyncMessage.MsgType.Terrain, m_scene.Heightmap.SaveToXmlString()));
+ return HandlerSuccess(msg, "Terrain sent");
+ }
+ case RegionSyncMessage.MsgType.GetRegionArchive:
+ {
+ IRegionArchiverModule archiver = m_scene.RequestModuleInterface();
+ if (archiver == null)
+ {
+ return HandlerFailure(msg, "Could not retrieve archiver module from scene");
+ }
+ MemoryStream ms = new MemoryStream();
+ // Remember the last time we archived this region to the ClientSyncServer
+ // Any updates after this time cannot be assumed to be in the archive stream
+ m_archive_time = DateTime.Now.Ticks;
+ archiver.ArchiveRegion(ms, Guid.Empty);
+ // ***
+ // The call to ArchiveRegion is asynchronous. We need a better way to know when it's done.
+ // For now, just sleep for 1 second. That will support a vary large region to be archived.
+ // Since this command is typically only executed when a new RegionSyncClient connects and
+ // is done on a RegionSyncServer thread, it should not impact other RegionSyncClients the
+ // RegionSyncServer, or the sim.
+ Thread.Sleep(1000);
+ Send(new RegionSyncMessage(RegionSyncMessage.MsgType.RegionArchive, ms.ToArray()));
+ return HandlerSuccess(msg, "Region archive sent");
+ }
+ case RegionSyncMessage.MsgType.AgentAdd:
+ {
+ OSDMap data = OSDParser.DeserializeJson(Encoding.ASCII.GetString(msg.Data)) as OSDMap;
+ if (data != null)
+ {
+ UUID agentID = data["agentID"].AsUUID();
+ string first = data["first"].AsString();
+ string last = data["last"].AsString();
+ Vector3 startPos = data["startPos"].AsVector3();
+
+ if (agentID != null && first != null && last != null && startPos != null)
+ {
+ RegionSyncAvatar av = new RegionSyncAvatar(m_scene, agentID, first, last, startPos);
+ lock (m_syncedAvatars)
+ {
+ if (m_syncedAvatars.ContainsKey(agentID))
+ {
+ return HandlerFailure(msg, String.Format( "Attempted to add duplicate avatar with agentID {0}", agentID));
+ }
+ m_syncedAvatars.Add(agentID, av);
+ }
+ m_scene.AddNewClient(av);
+ return HandlerSuccess(msg, String.Format("Handled AddAgent for UUID {0}", agentID));
+ }
+ }
+ return HandlerFailure(msg, "Could not parse AddAgent parameters");
+
+ }
+ case RegionSyncMessage.MsgType.AgentUpdate:
+ {
+ int len = 0;
+ AgentUpdatePacket.AgentDataBlock agentData = new AgentUpdatePacket.AgentDataBlock();
+ agentData.FromBytes(msg.Data, ref len);
+
+ UUID agentID = agentData.AgentID;
+
+ RegionSyncAvatar av;
+ bool found;
+ lock (m_syncedAvatars)
+ {
+ found = m_syncedAvatars.TryGetValue(agentData.AgentID, out av);
+ }
+ if(!found)
+ return HandlerFailure(msg, String.Format("Received agent update for non-existent avatar with UUID {0}", agentData.AgentID));
+
+ AgentUpdateArgs arg = new AgentUpdateArgs();
+ arg.AgentID = agentData.AgentID;
+ arg.BodyRotation = agentData.BodyRotation;
+ arg.CameraAtAxis = agentData.CameraAtAxis;
+ arg.CameraCenter = agentData.CameraCenter;
+ arg.CameraLeftAxis = agentData.CameraLeftAxis;
+ arg.CameraUpAxis = agentData.CameraUpAxis;
+ arg.ControlFlags = agentData.ControlFlags;
+ arg.Far = agentData.Far;
+ arg.Flags = agentData.Flags;
+ arg.HeadRotation = agentData.HeadRotation;
+ arg.SessionID = agentData.SessionID;
+ arg.State = agentData.State;
+
+ if( av.AgentUpdate(arg) )
+ return HandlerSuccess(msg, String.Format("Handled AgentUpdate for UUID {0}", agentID));
+ else
+ return HandlerFailure(msg, String.Format("Could not handle AgentUpdate UUID {0}", agentID));
+ }
+ default:
+ {
+ m_log.WarnFormat("{0} Unable to handle unsupported message type", LogHeader);
+ return false;
+ }
+ }
+ }
+
+ private bool HandlerSuccess(RegionSyncMessage msg, string handlerMessage)
+ {
+ m_log.WarnFormat("{0} Handled {1}: {2}", LogHeader, msg.ToString(), handlerMessage);
+ return true;
+ }
+
+ private bool HandlerFailure(RegionSyncMessage msg, string handlerMessage)
+ {
+ m_log.WarnFormat("{0} Unable to handle {1}: {2}", LogHeader, msg.ToString(), handlerMessage);
+ return false;
+ }
+
+ public void Send(RegionSyncMessage msg)
+ {
+ Send(msg.ToBytes());
+ //m_log.WarnFormat("{0} Sent {1}", LogHeader, msg.ToString());
+ }
+
+ private void Send(byte[] data)
+ {
+ if (m_tcpclient.Connected)
+ {
+ try
+ {
+ m_tcpclient.GetStream().Write(data, 0, data.Length);
+ }
+ catch (IOException e)
+ {
+ m_log.WarnFormat("{0} RegionSyncClient has disconnected.", LogHeader);
+ }
+ }
+ }
+
+ #region crud
+ // Should be part of the RegionSyncClient
+ /*
+ public string ReceiveMsg()
+ {
+ lock (m_outQ)
+ {
+ if (m_outQ.Count > 0)
+ {
+ return m_outQ.Dequeue();
+ }
+ }
+ return null;
+ }
+ * */
+ #endregion
+
+ }
+}
diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncMessage.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncMessage.cs
new file mode 100644
index 0000000000..6a0611feed
--- /dev/null
+++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncMessage.cs
@@ -0,0 +1,132 @@
+using System;
+using System.IO;
+using OpenMetaverse;
+using log4net;
+
+namespace OpenSim.Region.Examples.RegionSyncModule
+{
+ ///
+ /// A message for synchonization message between scenes
+ ///
+ public class RegionSyncMessage
+ {
+ #region MsgType Enum
+ public enum MsgType
+ {
+ Null,
+ //ConnectSyncClient,
+ //DisconnectSyncClient,
+ // CM -> SIM
+ AgentAdd,
+ AgentUpdate,
+ GetTerrain,
+ GetRegionArchive,
+ GetObjects,
+ GetObject,
+ ChatFromClient,
+ // SIM -> CM
+ Terrain,
+ RegionArchive,
+ AddObject,
+ UpdateObject,
+ RemoveObject,
+ AddAvatar,
+ UpdateAvatarTerse,
+ RemoveAvatar,
+ ChatFromSim,
+ // BIDIR
+ EchoRequest,
+ EchoResponse
+ }
+ #endregion
+
+ #region Member Data
+ private MsgType m_type;
+ private byte[] m_data;
+ #endregion
+
+ #region Constructors
+ public RegionSyncMessage(MsgType type, byte[] data)
+ {
+ m_type = type;
+ m_data = data;
+ }
+
+ public RegionSyncMessage(MsgType type, string msg)
+ {
+ m_type = type;
+ m_data = System.Text.Encoding.ASCII.GetBytes(msg + System.Environment.NewLine);
+ }
+
+ public RegionSyncMessage(MsgType type)
+ {
+ m_type = type;
+ m_data = new byte[0];
+ }
+
+ public RegionSyncMessage(Stream stream)
+ {
+ //ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
+ //try
+ {
+ m_type = (MsgType)Utils.BytesToInt(GetBytesFromStream(stream, 4));
+ int length = Utils.BytesToInt(GetBytesFromStream(stream, 4));
+ m_data = GetBytesFromStream(stream, length);
+ //log.WarnFormat("RegionSyncMessage Constructed {0} ({1} bytes)", m_type.ToString(), length);
+ }
+ /*
+ catch (Exception e)
+ {
+ log.WarnFormat("[REGION SYNC MESSAGE] RegionSyncMessage Constructor encountered an exception {0}", e.Message);
+ }
+ * */
+ }
+
+ private byte[] GetBytesFromStream(Stream stream, int count)
+ {
+ // Loop to receive the message length
+ byte[] ret = new byte[count];
+ int i = 0;
+ while (i < count)
+ {
+ i += stream.Read(ret, i, count - i);
+ }
+ return ret;
+ }
+
+ #endregion
+
+ #region Accessors
+ public MsgType Type
+ {
+ get { return m_type; }
+ }
+
+ public int Length
+ {
+ get { return m_data.Length; }
+ }
+
+ public byte[] Data
+ {
+ get { return m_data; }
+ }
+ #endregion
+
+ #region Conversions
+ public byte[] ToBytes()
+ {
+ byte[] buf = new byte[m_data.Length + 8];
+ Utils.IntToBytes((int)m_type, buf, 0);
+ Utils.IntToBytes(m_data.Length, buf, 4);
+ Array.Copy(m_data, 0, buf, 8, m_data.Length);
+ return buf;
+ }
+
+ public override string ToString()
+ {
+ return String.Format("{0} ({1} bytes)", m_type.ToString(), m_data.Length.ToString());
+ }
+ #endregion
+ }
+}
diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServer.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServer.cs
new file mode 100644
index 0000000000..99c77f4892
--- /dev/null
+++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServer.cs
@@ -0,0 +1,161 @@
+using System;
+using System.IO;
+using System.Net;
+using System.Net.Sockets;
+using System.Text;
+using System.Collections.Generic;
+using System.Threading;
+using OpenSim.Region.Framework.Scenes;
+using OpenSim.Region.Framework.Interfaces;
+using log4net;
+
+namespace OpenSim.Region.Examples.RegionSyncModule
+{
+ // The RegionSyncServer has a listener thread which accepts connections from RegionSyncClients
+ // and an additional thread to process updates to/from each RegionSyncClient.
+ public class RegionSyncServer
+ {
+ #region RegionSyncServer members
+ // Set the addr and port for TcpListener
+ private IPAddress m_addr;
+ private Int32 m_port;
+
+ // The local scene.
+ private Scene m_scene;
+
+ // A queue for incoming and outgoing traffic
+ // Incoming stuff can be from any client
+ // Outgoing stuff will be multicast to all clients
+ private Queue m_inQ = new Queue();
+ private Queue m_outQ = new Queue();
+
+ private ILog m_log;
+
+ // The listener and the thread which listens for connections from client managers
+ private TcpListener m_listener;
+ private Thread m_listenerThread;
+
+ // The list of clients and the threads handling IO for each client
+ // Lock should be used when client managers connect or disconnect
+ // while modifying the client list.
+ private Object clientLock = new Object();
+ private List m_client_views = new List();
+
+ // Check if any of the client views are in a connected state
+ public bool Synced
+ {
+ get
+ {
+ lock (clientLock)
+ {
+ foreach (RegionSyncClientView cv in m_client_views)
+ {
+ if (cv.Connected)
+ return true;
+ }
+ return false;
+ }
+ }
+ }
+ #endregion
+
+ // Constructor
+ public RegionSyncServer(Scene scene, string addr, int port)
+ {
+ m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
+ m_log.Warn("[REGION SYNC SERVER] Constructed");
+ m_scene = scene;
+ m_addr = IPAddress.Parse(addr);
+ m_port = port;
+ }
+
+ // Start the server
+ public void Start()
+ {
+ m_listenerThread = new Thread(new ThreadStart(Listen));
+ m_listenerThread.Name = "RegionSyncServer Listener";
+ m_log.WarnFormat("[REGION SYNC SERVER] Starting {0} thread", m_listenerThread.Name);
+ m_listenerThread.Start();
+ m_log.Warn("[REGION SYNC SERVER] Started");
+ }
+
+ // Stop the server and disconnect all RegionSyncClients
+ public void Shutdown()
+ {
+ lock (clientLock)
+ {
+ // Stop the listener and listening thread so no new clients are accepted
+ m_listener.Stop();
+ m_listenerThread.Abort();
+ m_listenerThread = null;
+ // Stop all existing client views and clear client list
+ foreach (RegionSyncClientView cv in m_client_views)
+ {
+ // Each client view will clean up after itself
+ cv.Shutdown();
+ }
+ m_client_views.Clear();
+ }
+ }
+
+ // Listen for connections from a new RegionSyncClient
+ // When connected, start the ReceiveLoop for the new client
+ private void Listen()
+ {
+ m_listener = new TcpListener(m_addr, m_port);
+
+ try
+ {
+ // Start listening for clients
+ m_listener.Start();
+ m_log.WarnFormat("[REGION SYNC SERVER] Listening on port {0}", m_port.ToString());
+
+ while (true)
+ {
+ // *** Move/Add TRY/CATCH to here, but we don't want to spin loop on the same error
+ m_log.Warn("[REGION SYNC SERVER] Waiting for a connection...");
+ TcpClient tcpclient = m_listener.AcceptTcpClient();
+ IPAddress addr = ((IPEndPoint)tcpclient.Client.RemoteEndPoint).Address;
+ int port = ((IPEndPoint)tcpclient.Client.RemoteEndPoint).Port;
+ lock (clientLock)
+ {
+ // Add the RegionSyncClientView to the list of clients
+ // *** Need to work on the timing order of starting the client view and adding to the server list
+ // so that messages coming from the scene do not get lost before the client view is added but
+ // not sent before it is ready to process them.
+ RegionSyncClientView rscv = new RegionSyncClientView(m_client_views.Count, m_scene, tcpclient);
+ m_log.WarnFormat("[REGION SYNC SERVER] New connection from {0}", rscv.Description);
+ m_client_views.Add(rscv);
+ }
+ }
+ }
+ catch (SocketException e)
+ {
+ m_log.WarnFormat("[REGION SYNC SERVER] [Listen] SocketException: {0}", e);
+ }
+ }
+
+ // Broadcast a message to all connected RegionSyncClients
+ public void Broadcast(RegionSyncMessage msg)
+ {
+ List clients = new List();
+ lock (clientLock)
+ {
+ foreach (RegionSyncClientView client in m_client_views)
+ {
+ if (client.Connected)
+ clients.Add(client);
+ }
+ }
+
+ if(clients.Count > 0 )
+ {
+ //m_log.WarnFormat("[REGION SYNC SERVER] Broadcasting {0} to all connected RegionSyncClients", msg.ToString());
+ foreach( RegionSyncClientView client in clients)
+ {
+ client.Send(msg);
+ }
+ }
+ }
+ }
+}
diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServerModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServerModule.cs
new file mode 100644
index 0000000000..bd9f387215
--- /dev/null
+++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServerModule.cs
@@ -0,0 +1,473 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSim Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using System.Collections.Generic;
+using System.Reflection;
+using Nini.Config;
+using OpenMetaverse;
+using OpenMetaverse.StructuredData;
+using OpenSim.Framework;
+using OpenSim.Framework.Client;
+using OpenSim.Region.Framework.Interfaces;
+using OpenSim.Region.Framework.Scenes;
+using OpenSim.Region.Framework.Scenes.Serialization;
+using log4net;
+using System.Net;
+using System.Net.Sockets;
+using System.Threading;
+
+namespace OpenSim.Region.Examples.RegionSyncModule
+{
+ public class RegionSyncServerModule : IRegionModule, IRegionSyncServerModule
+ {
+ #region IRegionModule Members
+ public void Initialise(Scene scene, IConfigSource config)
+ {
+ m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
+ IConfig syncConfig = config.Configs["RegionSyncModule"];
+ if (syncConfig == null || syncConfig.GetString("Mode", "server").ToLower() != "server")
+ {
+ m_active = false;
+ m_log.Warn("[REGION SYNC SERVER MODULE] Not in server mode. Shutting down.");
+ return;
+ }
+ m_serveraddr = syncConfig.GetString("ServerIPAddress", "127.0.0.1");
+ m_serverport = syncConfig.GetInt("ServerPort", 13000);
+ m_scene = scene;
+ m_scene.RegisterModuleInterface(this);
+ m_log.Warn("[REGION SYNC SERVER MODULE] Initialised");
+ }
+
+ public void PostInitialise()
+ {
+ if (!m_active)
+ return;
+
+ //m_scene.EventManager.OnObjectBeingRemovedFromScene += new EventManager.ObjectBeingRemovedFromScene(EventManager_OnObjectBeingRemovedFromScene);
+ //m_scene.EventManager.OnNewClient +=new EventManager.OnNewClientDelegate(EventManager_OnNewClient);
+ //m_scene.EventManager.OnNewPresence +=new EventManager.OnNewPresenceDelegate(EventManager_OnNewPresence);
+ //m_scene.EventManager.OnAvatarEnteringNewParcel += new EventManager.AvatarEnteringNewParcel(EventManager_OnAvatarEnteringNewParcel);
+ //m_scene.EventManager.OnClientMovement += new EventManager.ClientMovement(EventManager_OnClientMovement);
+ //m_scene.EventManager.OnLandObjectAdded += new EventManager.LandObjectAdded(EventManager_OnLandObjectAdded);
+ //m_scene.EventManager.OnLandObjectRemoved += new EventManager.LandObjectRemoved(EventManager_OnLandObjectRemoved);
+ m_scene.EventManager.OnRemovePresence += new EventManager.OnRemovePresenceDelegate(EventManager_OnRemovePresence);
+ m_scene.SceneGraph.OnObjectCreate += new ObjectCreateDelegate(SceneGraph_OnObjectCreate);
+ m_scene.SceneGraph.OnObjectDuplicate += new ObjectDuplicateDelegate(SceneGraph_OnObjectDuplicate);
+ //m_scene.SceneGraph.OnObjectRemove += new ObjectDeleteDelegate(SceneGraph_OnObjectRemove);
+ //m_scene.StatsReporter.OnSendStatsResult += new SimStatsReporter.SendStatResult(StatsReporter_OnSendStatsResult);
+
+ m_log.Warn("[REGION SYNC SERVER MODULE] Starting RegionSyncServer");
+ // Start the server and listen for RegionSyncClients
+ m_server = new RegionSyncServer(m_scene, m_serveraddr, m_serverport);
+ m_server.Start();
+ m_log.Warn("[REGION SYNC SERVER MODULE] Post-Initialised");
+ }
+
+
+ void IRegionModule.Close()
+ {
+ m_scene = null;
+ }
+
+ public string Name
+ {
+ get { return "RegionSyncModule"; }
+ }
+
+ public bool IsSharedModule
+ {
+ get { return false; }
+ }
+#endregion
+
+ #region IRegionSyncServerModule members
+ // Lock is used to synchronize access to the update status and both update queues
+ private object m_updateLock = new object();
+ private int m_sendingUpdates;
+ private Dictionary m_primUpdates = new Dictionary();
+ private Dictionary m_presenceUpdates = new Dictionary();
+
+ public void QueuePartForUpdate(SceneObjectPart part)
+ {
+ if (!Active || !Synced)
+ return;
+ lock (m_primUpdates)
+ {
+ m_primUpdates[part.ParentGroup.UUID] = part.ParentGroup;
+ }
+ //m_log.WarnFormat("[REGION SYNC SERVER MODULE] QueuePartForUpdate: {0}", part.UUID.ToString());
+ }
+
+ public void QueuePresenceForTerseUpdate(ScenePresence presence)
+ {
+ if (!Active || !Synced)
+ return;
+ lock (m_presenceUpdates)
+ {
+ m_presenceUpdates[presence.UUID] = presence;
+ }
+ //m_log.WarnFormat("[REGION SYNC SERVER MODULE] QueuePresenceForUpdate: {0}", presence.UUID.ToString());
+ }
+
+ public void SendUpdates()
+ {
+ if (!Active || !Synced)
+ return;
+
+ // Existing value of 1 indicates that updates are currently being sent so skip updates this pass
+ if (Interlocked.Exchange(ref m_sendingUpdates, 1) == 1)
+ {
+ m_log.WarnFormat("[REGION SYNC SERVER MODULE] SendUpdates(): An update thread is already running.");
+ return;
+ }
+
+ List primUpdates;
+ List presenceUpdates;
+ primUpdates = new List(m_primUpdates.Values);
+ presenceUpdates = new List(m_presenceUpdates.Values);
+ m_primUpdates.Clear();
+ m_presenceUpdates.Clear();
+
+ // This could be another thread for sending outgoing messages or just have the Queue functions
+ // create and queue the messages directly into the outgoing server thread.
+ System.Threading.ThreadPool.QueueUserWorkItem(delegate
+ {
+ // Sending the message when it's first queued would yield lower latency but much higher load on the simulator
+ // as parts may be updated many many times very quickly. Need to implement a higher resolution send in heartbeat
+ foreach (SceneObjectGroup sog in primUpdates)
+ {
+ if (!sog.IsDeleted)
+ {
+ string sogxml = SceneObjectSerializer.ToXml2Format(sog);
+ m_server.Broadcast(new RegionSyncMessage(RegionSyncMessage.MsgType.UpdateObject, sogxml));
+ }
+ }
+ foreach (ScenePresence presence in presenceUpdates)
+ {
+ if (!presence.IsDeleted)
+ {
+ OSDMap data = new OSDMap(4);
+ data["id"] = OSD.FromUUID(presence.UUID);
+ // Do not include offset for appearance height. That will be handled by RegionSyncClient before sending to viewers
+ data["pos"] = OSD.FromVector3(presence.AbsolutePosition);
+ data["vel"] = OSD.FromVector3(presence.Velocity);
+ data["rot"] = OSD.FromQuaternion(presence.Rotation);
+ RegionSyncMessage rsm = new RegionSyncMessage(RegionSyncMessage.MsgType.UpdateAvatarTerse, OSDParser.SerializeJsonString(data));
+ m_server.Broadcast(rsm);
+ }
+ }
+ // Indicate that the current batch of updates has been completed
+ Interlocked.Exchange(ref m_sendingUpdates, 0);
+ });
+ }
+
+ public void DeleteObject(ulong regionHandle, uint localID)
+ {
+ if (!Active || !Synced)
+ return;
+ OSDMap data = new OSDMap(2);
+ data["regionHandle"] = OSD.FromULong(regionHandle);
+ data["localID"] = OSD.FromUInteger(localID);
+ RegionSyncMessage rsm = new RegionSyncMessage(RegionSyncMessage.MsgType.RemoveObject, OSDParser.SerializeJsonString(data));
+ m_server.Broadcast(rsm);
+ }
+
+ public bool Active
+ {
+ get { return m_active; }
+ }
+
+ // Check if the sync server module is connected to any clients
+ public bool Synced
+ {
+ get
+ {
+ if (m_server == null || !m_server.Synced)
+ return false;
+ return true;
+ }
+ }
+
+ #region cruft
+#if false
+
+ public void QueuePartForUpdate(SceneObjectPart part)
+ {
+
+ m_server.Broadcast(string.Format("QueuePartForUpdate - Name:{0}, LocalID:{1}, UUID:{2}", part.Name, part.LocalId.ToString(), part.UUID.ToString()));
+ m_log.Warn(string.Format("QueuePartForUpdate - Name:{0}, LocalID:{1}, UUID:{2}", part.Name, part.LocalId.ToString(), part.UUID.ToString()));
+ //m_log.Warn(System.Environment.StackTrace);
+
+ }
+
+ public void SendPartFullUpdate(SceneObjectPart part)
+ {
+ /*
+ m_server.Broadcast(string.Format("SendPartFullUpdate - Name:{0}, LocalID:{1}, UUID:{2}", part.Name, part.LocalId.ToString(), part.UUID.ToString()));
+ m_log.Warn(string.Format("SendPartFullUpdate - Name:{0}, LocalID:{1}, UUID:{2}", part.Name, part.LocalId.ToString(), part.UUID.ToString()));
+ * */
+ }
+ public void SendPartTerseUpdate(SceneObjectPart part)
+ {
+ /*
+ m_server.Broadcast(string.Format("SendPartTerseUpdate - Name:{0}, LocalID:{1}, UUID:{2}", part.Name, part.LocalId.ToString(), part.UUID.ToString()));
+ m_log.Warn(string.Format("SendPartTerseUpdate - Name:{0}, LocalID:{1}, UUID:{2}", part.Name, part.LocalId.ToString(), part.UUID.ToString()));
+ * */
+ }
+ public void SendShutdownConnectionNotice(Scene scene)
+ {
+ /*
+ m_server.Broadcast("SendShutdownConnectionNotice");
+ m_log.Warn("SendShutdownConnectionNotice");
+ * */
+ }
+ public void SendKillObject(ulong regionHandle, uint localID)
+ {
+ /*
+ m_server.Broadcast(string.Format("SendKillObject - regionHandle:{0}, localID:{1}", regionHandle.ToString(), localID.ToString()));
+ m_log.Warn(string.Format("SendKillObject - regionHandle:{0}, localID:{1}", regionHandle.ToString(), localID.ToString()));
+ m_log.Warn(System.Environment.StackTrace);
+ * */
+ }
+#endif
+ #endregion
+ #endregion
+
+ #region RegionSyncServerModule members
+ private bool m_active = true;
+ private string m_serveraddr;
+ private int m_serverport;
+ private Scene m_scene;
+ //private IClientAPI m_clientAggregator;
+ private ILog m_log;
+ //private int m_moveCounter = 0;
+ private RegionSyncServer m_server = null;
+ #endregion
+
+ #region Event Handlers
+ private void SceneGraph_OnObjectCreate(EntityBase entity)
+ {
+ if (entity is SceneObjectGroup)
+ {
+ string sogxml = SceneObjectSerializer.ToXml2Format((SceneObjectGroup)entity);
+ RegionSyncMessage rsm = new RegionSyncMessage(RegionSyncMessage.MsgType.AddObject, sogxml);
+ m_server.Broadcast(rsm);
+ }
+ else
+ {
+ m_log.Warn("SceneGraph_OnObjectCreate called with non-SceneObjectGroup");
+ }
+ }
+
+ private void SceneGraph_OnObjectDuplicate(EntityBase original, EntityBase copy)
+ {
+ if (original is SceneObjectGroup && copy is SceneObjectGroup)
+ {
+ string sogxml = SceneObjectSerializer.ToXml2Format((SceneObjectGroup)copy);
+ RegionSyncMessage rsm = new RegionSyncMessage(RegionSyncMessage.MsgType.AddObject, sogxml);
+ m_server.Broadcast(rsm);
+ }
+ else
+ {
+ m_log.Warn("SceneGraph_OnObjectDuplicate called with non-SceneObjectGroup");
+ }
+ }
+
+ private void SceneGraph_OnObjectRemove(EntityBase entity)
+ {
+ if (entity is SceneObjectGroup)
+ {
+ // No reason to send the entire object, just send the UUID to be deleted
+ RegionSyncMessage rsm = new RegionSyncMessage(RegionSyncMessage.MsgType.RemoveObject, entity.UUID.ToString());
+ m_server.Broadcast(rsm);
+ }
+ else
+ {
+ m_log.Warn("SceneGraph_OnObjectDelete called with non-SceneObjectGroup");
+ }
+ }
+
+ // A ficticious event
+ public void Scene_AddNewPrim(SceneObjectGroup sog)
+ {
+ }
+
+ /*
+ public void StatsReporter_OnSendStatsResult(SimStats stats)
+ {
+ //m_log.Warn("SendSimStats");
+ }
+
+ void EventManager_OnObjectBeingRemovedFromScene(SceneObjectGroup sog)
+ {
+ string msg = (string.Format("EventManager_OnObjectBeingRemovedFromScene" + System.Environment.NewLine +
+ "REMOVE: ownerID {0}, groupID {1}, pos {2}, rot {3}, shape {4}, id {5}, localID {6}", sog.OwnerID.ToString(), sog.GroupID.ToString(), sog.RootPart.GroupPosition.ToString(), sog.Rotation.ToString(), sog.RootPart.Shape.ToString(), sog.UUID.ToString(), sog.LocalId.ToString()));
+ m_server.Broadcast(msg);
+ m_log.Warn("[REGION SYNC SERVER MODULE] " + msg);
+ DebugSceneStats();
+ }
+
+ void SceneGraph_OnObjectRemove(EntityBase obj)
+ {
+ SceneObjectGroup sog = (SceneObjectGroup)obj;
+ string msg = (string.Format("SceneGraph_OnObjectRemove" + System.Environment.NewLine +
+ "REMOVE: ownerID {0}, groupID {1}, pos {2}, rot {3}, shape {4}, id {5}, localID {6}", sog.OwnerID.ToString(), sog.GroupID.ToString(), sog.RootPart.GroupPosition.ToString(), sog.Rotation.ToString(), sog.RootPart.Shape.ToString(), sog.UUID.ToString(), sog.LocalId.ToString()));
+ m_server.Broadcast(msg);
+ m_log.Warn("[REGION SYNC SERVER MODULE] " + msg);
+ DebugSceneStats();
+ }
+
+ void SceneGraph_OnObjectDuplicate(EntityBase original, EntityBase clone)
+ {
+ SceneObjectGroup sog1 = (SceneObjectGroup)original;
+ SceneObjectGroup sog2 = (SceneObjectGroup)clone;
+ string msg = (string.Format("SceneGraph_OnObjectDuplicate" +
+ System.Environment.NewLine +
+ "ORIGINAL: ownerID {0}, groupID {1}, pos {2}, rot {3}, shape {4}, id {5}, localID {6}" +
+ System.Environment.NewLine +
+ "CLONE: ownerID {7}, groupID {8}, pos {9}, rot {10}, shape {11}, id {12}, localID {13}",
+ sog1.OwnerID.ToString(), sog1.GroupID.ToString(), sog1.RootPart.GroupPosition.ToString(), sog1.Rotation.ToString(), sog1.RootPart.Shape.ToString(), sog1.UUID.ToString(), sog1.LocalId.ToString(),
+ sog2.OwnerID.ToString(), sog2.GroupID.ToString(), sog2.RootPart.GroupPosition.ToString(), sog2.Rotation.ToString(), sog2.RootPart.Shape.ToString(), sog2.UUID.ToString(), sog2.LocalId.ToString()));
+ m_server.Broadcast(msg);
+ m_log.Warn("[REGION SYNC SERVER MODULE] " + msg);
+
+ m_log.WarnFormat("[REGION SYNC SERVER MODULE] SceneGraph_OnObjectDuplicate");
+ DebugSceneStats();
+ }
+
+ void SceneGraph_OnObjectCreate(EntityBase obj)
+ {
+ SceneObjectGroup sog = (SceneObjectGroup)obj;
+ string msg = (string.Format("SceneGraph_OnObjectCreate" + System.Environment.NewLine +
+ "CREATE: ownerID {0}, groupID {1}, pos {2}, rot {3}, shape {4}, id {5}, localID {6}", sog.OwnerID.ToString(), sog.GroupID.ToString(), sog.RootPart.GroupPosition.ToString(), sog.Rotation.ToString(), sog.RootPart.Shape.ToString(), sog.UUID.ToString(), sog.LocalId.ToString()));
+ m_server.Broadcast(msg);
+ m_log.Warn("[REGION SYNC SERVER MODULE] " + msg);
+ //DebugSceneStats();
+
+ }
+
+ void EventManager_OnLandObjectRemoved(UUID globalID)
+ {
+ m_log.WarnFormat("[REGION SYNC SERVER MODULE] EventManager_OnLandObjectRemoved");
+ DebugSceneStats();
+ }
+
+ void EventManager_OnLandObjectAdded(ILandObject newParcel)
+ {
+ m_log.WarnFormat("[REGION SYNC SERVER MODULE] EventManager_OnLandObjectAdded");
+ DebugSceneStats();
+ }
+
+ void EventManager_OnClientMovement(ScenePresence client)
+ {
+
+ m_moveCounter++;
+ if (m_moveCounter % 100 == 0)
+ {
+ string msg = (string.Format("EventManager_OnClientMovement - Event has been triggered 100 times"));
+ m_server.Broadcast(msg);
+ m_log.Warn("REGION SYNC SERVER MODULE] " + msg);
+ }
+ }
+
+
+ void EventManager_OnAvatarEnteringNewParcel(ScenePresence avatar, int localLandID, UUID regionID)
+ {
+ m_log.WarnFormat("[REGION SYNC SERVER MODULE] (OnAvatarEnteringNewParcel) Avatar \"{0}\" has joined the scene (1) {2} {3} {4}", avatar.Name, avatar.ControllingClient.AgentId.ToString(), avatar.UUID.ToString(), localLandID, regionID.ToString());
+ DebugSceneStats();
+ }
+
+
+ private void EventManager_OnNewClient(IClientAPI client)
+ {
+ ScenePresence presence = m_scene.GetScenePresence(client.AgentId);
+ if (presence != null)
+ {
+ m_log.WarnFormat("[REGION SYNC SERVER MODULE] (OnNewClient) \"{0}\"", presence.Name);
+ DebugSceneStats();
+ }
+ else
+ {
+ m_log.WarnFormat("[REGION SYNC SERVER MODULE] (OnNewClient) A new client connected but module could not get ScenePresence");
+ }
+ }
+
+ private void EventManager_OnNewPresence(ScenePresence presence)
+ {
+ m_log.WarnFormat("[REGION SYNC SERVER MODULE] Avatar \"{0}\" (1) {2} has joined the scene", presence.Firstname + " " + presence.Lastname, presence.ControllingClient.AgentId.ToString(), presence.UUID.ToString());
+ DebugSceneStats();
+ }
+ * */
+
+ private void EventManager_OnRemovePresence(UUID agentID)
+ {
+ ScenePresence avatar;
+ if (m_scene.TryGetAvatar(agentID, out avatar))
+ {
+ m_log.WarnFormat("[REGION SYNC SERVER MODULE] Avatar \"{0}\" (1) {2} has left the scene", avatar.Firstname + " " + avatar.Lastname, agentID.ToString(), avatar.UUID.ToString());
+ }
+ else
+ {
+ m_log.WarnFormat("[REGION SYNC SERVER MODULE] Avatar \"unknown\" has left the scene");
+ }
+ OSDArray data = new OSDArray();
+ data.Add(OSD.FromULong(avatar.RegionHandle));
+ data.Add(OSD.FromUInteger(avatar.LocalId));
+ RegionSyncMessage rsm = new RegionSyncMessage(RegionSyncMessage.MsgType.RemoveAvatar, data.ToString());
+ m_server.Broadcast(rsm);
+ }
+
+ #endregion
+
+
+ /*
+ private void DebugSceneStats()
+ {
+ List avatars = m_scene.GetAvatars();
+ List entities = m_scene.GetEntities();
+ m_log.WarnFormat("There are {0} avatars and {1} entities in the scene", avatars.Count, entities.Count);
+ }
+
+ public IClientAPI ClientAggregator
+ {
+ get {return m_clientAggregator;}
+ }
+
+ private void AddAvatars()
+ {
+ for (int i = 0; i < 1; i++)
+ {
+ MyNpcCharacter m_character = new MyNpcCharacter(m_scene, this);
+ m_scene.AddNewClient(m_character);
+
+ m_scene.AgentCrossing(m_character.AgentId, m_character.StartPos, false);
+ }
+ }
+ */
+ }
+}
diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
index d052f38a2c..f248da6392 100644
--- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
+++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
@@ -56,6 +56,7 @@ namespace OpenSim.Region.Examples.SimpleModule
public event ImprovedInstantMessage OnInstantMessage;
public event ChatMessage OnChatFromClient;
+ public event ChatMessageRaw OnChatFromClientRaw;
public event TextureRequest OnRequestTexture;
public event RezObject OnRezObject;
public event ModifyTerrain OnModifyTerrain;
@@ -86,6 +87,7 @@ namespace OpenSim.Region.Examples.SimpleModule
public event GenericCall1 OnCompleteMovementToRegion;
public event UpdateAgent OnPreAgentUpdate;
public event UpdateAgent OnAgentUpdate;
+ public event UpdateAgentRaw OnAgentUpdateRaw;
public event AgentRequestSit OnAgentRequestSit;
public event AgentSit OnAgentSit;
public event AvatarPickerRequest OnAvatarPickerRequest;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index c510dc81a3..2c33aacc94 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -319,6 +319,33 @@ namespace OpenSim.Region.Framework.Scenes
protected IDialogModule m_dialogModule;
protected IEntityTransferModule m_teleportModule;
+ protected IRegionSyncServerModule m_regionSyncServerModule;
+ protected IRegionSyncClientModule m_regionSyncClientModule;
+
+ public Object regionSyncLock = new Object();
+
+ public IRegionSyncServerModule RegionSyncServerModule
+ {
+ get { return m_regionSyncServerModule; }
+ set { m_regionSyncServerModule = value; }
+ }
+
+ public IRegionSyncClientModule RegionSyncClientModule
+ {
+ get { return m_regionSyncClientModule; }
+ set { m_regionSyncClientModule = value; }
+ }
+
+ public bool IsSyncedClient()
+ {
+ return (m_regionSyncClientModule != null && m_regionSyncClientModule.Active && m_regionSyncClientModule.Synced);
+ }
+
+ public bool IsSyncedServer()
+ {
+ return (m_regionSyncServerModule != null && m_regionSyncServerModule.Active && m_regionSyncServerModule.Synced);
+ }
+
protected ICapabilitiesModule m_capsModule;
public ICapabilitiesModule CapsModule
{
@@ -1219,6 +1246,8 @@ namespace OpenSim.Region.Framework.Scenes
m_dialogModule = RequestModuleInterface();
m_capsModule = RequestModuleInterface();
m_teleportModule = RequestModuleInterface();
+ RegionSyncServerModule = RequestModuleInterface();
+ RegionSyncClientModule = RequestModuleInterface();
}
#endregion
@@ -1290,6 +1319,9 @@ namespace OpenSim.Region.Framework.Scenes
if (m_frame % m_update_presences == 0)
m_sceneGraph.UpdatePresences();
+ if (IsSyncedServer())
+ m_regionSyncServerModule.SendUpdates();
+
int tmpPhysicsMS2 = Util.EnvironmentTickCount();
if ((m_frame % m_update_physics == 0) && m_physics_enabled)
m_sceneGraph.UpdatePreparePhysics();
@@ -2449,9 +2481,15 @@ namespace OpenSim.Region.Framework.Scenes
///
public override void AddNewClient(IClientAPI client)
{
+ AddNewClient2(client, true);
+ }
+ public void AddNewClient2(IClientAPI client, bool managed)
+ {
+
bool vialogin = false;
- m_clientManager.Add(client);
+ if(managed)
+ m_clientManager.Add(client);
CheckHeartbeat();
SubscribeToClientEvents(client);
@@ -3069,21 +3107,28 @@ namespace OpenSim.Region.Framework.Scenes
}
m_eventManager.TriggerOnRemovePresence(agentID);
- ForEachClient(
- delegate(IClientAPI client)
- {
- //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway
- try { client.SendKillObject(avatar.RegionHandle, avatar.LocalId); }
- catch (NullReferenceException) { }
- });
- ForEachScenePresence(
- delegate(ScenePresence presence) { presence.CoarseLocationChange(); });
-
- IAgentAssetTransactions agentTransactions = this.RequestModuleInterface();
- if (agentTransactions != null)
+ if(IsSyncedServer())
+ RegionSyncServerModule.DeleteObject(avatar.RegionHandle, avatar.LocalId);
+ else
{
- agentTransactions.RemoveAgentAssetTransactions(agentID);
+ ForEachClient(
+ delegate(IClientAPI client)
+ {
+ //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway
+ try { client.SendKillObject(avatar.RegionHandle, avatar.LocalId); }
+ catch (NullReferenceException) { }
+ });
+
+
+ ForEachScenePresence(
+ delegate(ScenePresence presence) { presence.CoarseLocationChange(); });
+
+ IAgentAssetTransactions agentTransactions = this.RequestModuleInterface();
+ if (agentTransactions != null)
+ {
+ agentTransactions.RemoveAgentAssetTransactions(agentID);
+ }
}
// Remove the avatar from the scene
@@ -3154,7 +3199,12 @@ namespace OpenSim.Region.Framework.Scenes
return;
}
}
- ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); });
+
+ // REGION SYNC
+ if( IsSyncedServer() )
+ RegionSyncServerModule.DeleteObject(m_regionHandle, localID);
+ else
+ ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); });
}
#endregion
@@ -4198,8 +4248,11 @@ namespace OpenSim.Region.Framework.Scenes
///
///
///
+ static int s_ForEachPresenceCounter = 0;
public void ForEachScenePresence(Action action)
{
+ if (IsSyncedServer())
+ return;
// We don't want to try to send messages if there are no avatars.
if (m_sceneGraph != null)
{
@@ -4289,11 +4342,18 @@ namespace OpenSim.Region.Framework.Scenes
public void ForEachClient(Action action)
{
+ // REGION SYNC
+ if (IsSyncedServer())
+ return;
+
ForEachClient(action, m_useAsyncWhenPossible);
}
public void ForEachClient(Action action, bool doAsynchronous)
{
+ // REGION SYNC
+ if (IsSyncedServer())
+ return;
// FIXME: Asynchronous iteration is disabled until we have a threading model that
// can support calling this function from an async packet handler without
// potentially deadlocking
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index d944834f70..ce1d898752 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -801,7 +801,7 @@ namespace OpenSim.Region.Framework.Scenes
///
///
/// null if no scene object group containing that prim is found
- private SceneObjectGroup GetGroupByPrim(UUID fullID)
+ public SceneObjectGroup GetGroupByPrim(UUID fullID)
{
SceneObjectGroup sog;
lock (SceneObjectGroupsByFullID)
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 88deedf174..fcbbb0eac7 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -1268,22 +1268,27 @@ namespace OpenSim.Region.Framework.Scenes
foreach (SceneObjectPart part in m_parts.Values)
{
// part.Inventory.RemoveScriptInstances();
-
- ScenePresence[] avatars = Scene.GetScenePresences();
- for (int i = 0; i < avatars.Length; i++)
+ // REGION SYNC
+ if (Scene.IsSyncedServer())
{
- if (avatars[i].ParentID == LocalId)
+ Scene.RegionSyncServerModule.DeleteObject(part.RegionHandle, part.LocalId);
+ return;
+ }
+
+ Scene.ForEachScenePresence(delegate(ScenePresence avatar)
+ {
+ if (avatar.ParentID == LocalId)
{
- avatars[i].StandUp();
+ avatar.StandUp();
}
if (!silent)
{
part.UpdateFlag = 0;
if (part == m_rootPart)
- avatars[i].ControllingClient.SendKillObject(m_regionHandle, part.LocalId);
+ avatar.ControllingClient.SendKillObject(m_regionHandle, part.LocalId);
}
- }
+ });
}
}
}
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index a2b98b9f85..26e5f92a13 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -1260,11 +1260,11 @@ namespace OpenSim.Region.Framework.Scenes
///
public void AddFullUpdateToAllAvatars()
{
- ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences();
- for (int i = 0; i < avatars.Length; i++)
- {
- avatars[i].SceneViewer.QueuePartForUpdate(this);
- }
+ // REGION SYNC
+ if (m_parentGroup.Scene.IsSyncedServer())
+ m_parentGroup.Scene.RegionSyncServerModule.QueuePartForUpdate(this);
+
+ m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) { avatar.SceneViewer.QueuePartForUpdate(this); });
}
public void AddFullUpdateToAvatar(ScenePresence presence)
@@ -1285,11 +1285,10 @@ namespace OpenSim.Region.Framework.Scenes
/// Terse updates
public void AddTerseUpdateToAllAvatars()
{
- ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences();
- for (int i = 0; i < avatars.Length; i++)
- {
- avatars[i].SceneViewer.QueuePartForUpdate(this);
- }
+ if (m_parentGroup.Scene.IsSyncedServer())
+ m_parentGroup.Scene.RegionSyncServerModule.QueuePartForUpdate(this);
+
+ m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) { avatar.SceneViewer.QueuePartForUpdate(this); });
}
public void AddTerseUpdateToAvatar(ScenePresence presence)
@@ -2877,11 +2876,10 @@ namespace OpenSim.Region.Framework.Scenes
///
public void SendFullUpdateToAllClients()
{
- ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences();
- for (int i = 0; i < avatars.Length; i++)
+ m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar)
{
- SendFullUpdate(avatars[i].ControllingClient, avatars[i].GenerateClientFlags(UUID));
- }
+ SendFullUpdate(avatar.ControllingClient, avatar.GenerateClientFlags(UUID));
+ });
}
///
@@ -2890,13 +2888,12 @@ namespace OpenSim.Region.Framework.Scenes
///
public void SendFullUpdateToAllClientsExcept(UUID agentID)
{
- ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences();
- for (int i = 0; i < avatars.Length; i++)
+ m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar)
{
// Ugly reference :(
- if (avatars[i].UUID != agentID)
- SendFullUpdate(avatars[i].ControllingClient, avatars[i].GenerateClientFlags(UUID));
- }
+ if (avatar.UUID != agentID)
+ SendFullUpdate(avatar.ControllingClient, avatar.GenerateClientFlags(UUID));
+ });
}
///
@@ -3096,11 +3093,7 @@ namespace OpenSim.Region.Framework.Scenes
///
public void SendTerseUpdateToAllClients()
{
- ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences();
- for (int i = 0; i < avatars.Length; i++)
- {
- SendTerseUpdateToClient(avatars[i].ControllingClient);
- }
+ m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) { SendTerseUpdateToClient(avatar.ControllingClient); });
}
public void SetAttachmentPoint(uint AttachmentPoint)
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 6f16ff347c..edfe24ddd2 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -688,9 +688,12 @@ namespace OpenSim.Region.Framework.Scenes
AbsolutePosition = posLastSignificantMove = m_CameraCenter =
m_lastCameraCenter = m_controllingClient.StartPos;
- m_reprioritization_timer = new Timer(world.ReprioritizationInterval);
- m_reprioritization_timer.Elapsed += new ElapsedEventHandler(Reprioritize);
- m_reprioritization_timer.AutoReset = false;
+ if (!m_scene.IsSyncedServer())
+ {
+ m_reprioritization_timer = new Timer(world.ReprioritizationInterval);
+ m_reprioritization_timer.Elapsed += new ElapsedEventHandler(Reprioritize);
+ m_reprioritization_timer.AutoReset = false;
+ }
AdjustKnownSeeds();
@@ -730,7 +733,10 @@ namespace OpenSim.Region.Framework.Scenes
m_controllingClient.OnSetAppearance += SetAppearance;
m_controllingClient.OnCompleteMovementToRegion += CompleteMovement;
//m_controllingClient.OnCompleteMovementToRegion += SendInitialData;
- m_controllingClient.OnAgentUpdate += HandleAgentUpdate;
+
+ // REGION SYNC
+ if(!m_scene.IsSyncedClient())
+ m_controllingClient.OnAgentUpdate += HandleAgentUpdate;
m_controllingClient.OnAgentRequestSit += HandleAgentRequestSit;
m_controllingClient.OnAgentSit += HandleAgentSit;
m_controllingClient.OnSetAlwaysRun += HandleSetAlwaysRun;
@@ -912,14 +918,11 @@ namespace OpenSim.Region.Framework.Scenes
m_isChildAgent = false;
- ScenePresence[] animAgents = m_scene.GetScenePresences();
- for (int i = 0; i < animAgents.Length; i++)
+ m_scene.ForEachScenePresence(delegate(ScenePresence presence)
{
- ScenePresence presence = animAgents[i];
-
if (presence != this)
presence.Animator.SendAnimPackToClient(ControllingClient);
- }
+ });
m_scene.EventManager.TriggerOnMakeRootAgent(this);
}
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
index 18859463a8..a91e863cf2 100644
--- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
+++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
@@ -652,6 +652,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
public event GenericMessage OnGenericMessage;
public event ImprovedInstantMessage OnInstantMessage;
public event ChatMessage OnChatFromClient;
+ public event ChatMessageRaw OnChatFromClientRaw;
public event TextureRequest OnRequestTexture;
public event RezObject OnRezObject;
public event ModifyTerrain OnModifyTerrain;
@@ -682,6 +683,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
public event GenericCall1 OnCompleteMovementToRegion;
public event UpdateAgent OnPreAgentUpdate;
public event UpdateAgent OnAgentUpdate;
+ public event UpdateAgentRaw OnAgentUpdateRaw;
public event AgentRequestSit OnAgentRequestSit;
public event AgentSit OnAgentSit;
public event AvatarPickerRequest OnAvatarPickerRequest;
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index 77958eb003..dd77451c44 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
@@ -163,6 +163,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
public event GenericMessage OnGenericMessage;
public event ImprovedInstantMessage OnInstantMessage;
public event ChatMessage OnChatFromClient;
+ public event ChatMessageRaw OnChatFromClientRaw;
public event TextureRequest OnRequestTexture;
public event RezObject OnRezObject;
public event ModifyTerrain OnModifyTerrain;
@@ -192,6 +193,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
public event GenericCall1 OnCompleteMovementToRegion;
public event UpdateAgent OnPreAgentUpdate;
public event UpdateAgent OnAgentUpdate;
+ public event UpdateAgentRaw OnAgentUpdateRaw;
public event AgentRequestSit OnAgentRequestSit;
public event AgentSit OnAgentSit;
public event AvatarPickerRequest OnAvatarPickerRequest;
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs
index 5fff279973..bbfd7c4a56 100644
--- a/OpenSim/Tests/Common/Mock/TestClient.cs
+++ b/OpenSim/Tests/Common/Mock/TestClient.cs
@@ -68,6 +68,7 @@ namespace OpenSim.Tests.Common.Mock
public event ImprovedInstantMessage OnInstantMessage;
public event ChatMessage OnChatFromClient;
+ public event ChatMessageRaw OnChatFromClientRaw;
public event TextureRequest OnRequestTexture;
public event RezObject OnRezObject;
public event ModifyTerrain OnModifyTerrain;
@@ -97,6 +98,7 @@ namespace OpenSim.Tests.Common.Mock
public event GenericCall2 OnRequestWearables;
public event GenericCall1 OnCompleteMovementToRegion;
public event UpdateAgent OnPreAgentUpdate;
+ public event UpdateAgentRaw OnAgentUpdateRaw;
public event UpdateAgent OnAgentUpdate;
public event AgentRequestSit OnAgentRequestSit;
public event AgentSit OnAgentSit;
diff --git a/bin/OpenSim.32BitLaunch.exe.config b/bin/OpenSim.32BitLaunch.exe.config
index 6ac0206e6c..74d2427eb3 100644
--- a/bin/OpenSim.32BitLaunch.exe.config
+++ b/bin/OpenSim.32BitLaunch.exe.config
@@ -24,7 +24,7 @@
-
+