public RegionSyncListener(RegionSyncListenerInfo listenerInfo, RegionSyncModule regionSyncModule) { m_listenerInfo = listenerInfo; m_regionSyncModule = regionSyncModule; m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); }
/// <summary> /// The constructor that will be called when a SyncConnector is created passively: a remote SyncConnector has initiated the connection. /// </summary> /// <param name="connectorNum"></param> /// <param name="tcpclient"></param> public SyncConnector(int connectorNum, TcpClient tcpclient, RegionSyncModule syncModule) { m_tcpConnection = tcpclient; m_connectorNum = connectorNum; m_regionSyncModule = syncModule; lastStatTime = DateTime.Now; m_syncState = SyncConnectorState.Initialization; m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); }
/// <summary> /// The constructor that will be called when a SyncConnector is created actively: it is created to send connection request to a remote listener /// </summary> /// <param name="connectorNum"></param> /// <param name="listenerInfo"></param> public SyncConnector(int connectorNum, RegionSyncListenerInfo listenerInfo, RegionSyncModule syncModule) { m_remoteListenerInfo = listenerInfo; m_connectorNum = connectorNum; m_regionSyncModule = syncModule; lastStatTime = DateTime.Now; m_syncState = SyncConnectorState.Initialization; m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); }
/// <summary> /// For each property in updatedProperties, (1) if the value in local sop/sp's /// data is different than that in SyncInfo, and what's in SyncInfo /// has an older timestamp, then update that property's value and syncInfo /// in SyncInfo; (2) otherwise, skip the property and do nothing. /// </summary> /// <param name="part"></param> /// <param name="updatedProperties"></param> /// <returns>The list properties among updatedProperties whose value have been copied over to SyncInfo.</returns> public HashSet <SyncableProperties.Type> UpdateSyncInfoByLocal(UUID uuid, HashSet <SyncableProperties.Type> updatedProperties) { SyncInfoBase thisSyncInfo = null; bool found = false; lock (m_syncLock){ found = m_syncedUUIDs.TryGetValue(uuid, out thisSyncInfo); } if (found) { // DebugLog.WarnFormat("[SYNC INFO MANAGER] UpdateSyncInfoByLocal SyncInfo for {0} FOUND.", uuid); return(thisSyncInfo.UpdatePropertiesByLocal(uuid, updatedProperties, RegionSyncModule.NowTicks(), m_regionSyncModule.SyncID)); } // DebugLog.WarnFormat("[SYNC INFO MANAGER] UpdateSyncInfoByLocal SyncInfo for {0} NOT FOUND.", uuid); return(new HashSet <SyncableProperties.Type>()); }
public override bool ConvertIn(RegionSyncModule pRegionContext) { bool ret = false; if (base.ConvertIn(pRegionContext)) { AgentID = DataMap["agentID"].AsUUID(); ItemID = DataMap["itemID"].AsUUID(); PrimID = DataMap["primID"].AsUUID(); IsRunning = DataMap["running"].AsBoolean(); AssetID = DataMap["assetID"].AsUUID(); ret = true; } return ret; }
public override bool HandleIn(RegionSyncModule pRegionContext) { bool ret = false; if (base.HandleIn(pRegionContext)) { m_log.DebugFormat("{0} SyncMsgChatFromClient: {1} : {2}", LogHeader, ChatMessage.From, ChatMessage.Message); if (ChatMessage.Sender is RegionSyncAvatar) ((RegionSyncAvatar)ChatMessage.Sender).SyncChatFromClient(ChatMessage); ret = true; } return ret; }
public override bool HandleIn(RegionSyncModule pRegionContext) { if (base.HandleIn(pRegionContext)) { if (SyncedProperties != null && SyncedProperties.Count > 0) { // Update local sync info and scene object/presence pRegionContext.RememberLocallyGeneratedEvent(MType); HashSet<SyncableProperties.Type> propertiesUpdated = pRegionContext.InfoManager.UpdateSyncInfoBySync(Uuid, SyncedProperties); if (propertiesUpdated.Contains(RegionSync.SyncableProperties.Type.AvatarAppearance)) m_log.DebugFormat("{0} SyncMsgUpdatedProperties:HandleIn AvatarAppearance for uuid {1}", LogHeader, Uuid); pRegionContext.ForgetLocallyGeneratedEvent(); // Do our own detail logging after we know which properties are actually updated (in propertiesUpdated) pRegionContext.DetailedUpdateLogging(Uuid, propertiesUpdated, "RecUpdateN", ConnectorContext.otherSideActorID, DataLength); // Relay the update properties if (pRegionContext.IsSyncRelay) pRegionContext.EnqueueUpdatedProperty(Uuid, propertiesUpdated); } } return true; }
public SyncMsgDelinkObject(RegionSyncModule pRegionContext, List<UUID> pDelinkPrimIDs, List<UUID> pBeforeDlinkGroupIDs, List<SceneObjectGroup> pAfterDelinkGroups) : base(MsgType.DelinkObject, pRegionContext) { DelinkPrimIDs = pDelinkPrimIDs; BeforeDelinkGroupIDs = pBeforeDlinkGroupIDs; AfterDelinkGroups = pAfterDelinkGroups; }
public override bool ConvertOut(RegionSyncModule pRegionContext) { lock (m_dataLock) { if (Dir == Direction.Out && DataMap == null) { OSDMap data = new OSDMap(); data["partCount"] = OSD.FromInteger(DelinkPrimIDs.Count); int partNum = 0; foreach (UUID partUUID in DelinkPrimIDs) { string partTempID = "part" + partNum; data[partTempID] = OSD.FromUUID(partUUID); partNum++; } //We also include the IDs of beforeDelinkGroups, for now it is more for sanity checking at the receiving end, so that the receiver //could make sure its delink starts with the same linking state of the groups/prims. data["beforeGroupsCount"] = OSD.FromInteger(BeforeDelinkGroupIDs.Count); int groupNum = 0; foreach (UUID affectedGroupUUID in BeforeDelinkGroupIDs) { string groupTempID = "beforeGroup" + groupNum; data[groupTempID] = OSD.FromUUID(affectedGroupUUID); groupNum++; } //include the property values of each object after delinking, for synchronizing the values data["afterGroupsCount"] = OSD.FromInteger(AfterDelinkGroups.Count); groupNum = 0; foreach (SceneObjectGroup afterGroup in AfterDelinkGroups) { string groupTempID = "afterGroup" + groupNum; //string sogxml = SceneObjectSerializer.ToXml2Format(afterGroup); //data[groupTempID] = OSD.FromString(sogxml); OSDMap encodedSOG = EncodeSceneObject(afterGroup, pRegionContext); data[groupTempID] = encodedSOG; groupNum++; } DataMap = data; } } return base.ConvertOut(pRegionContext); }
public SyncMsgAttach(RegionSyncModule pRegionContext, UUID pPrimID, UUID pItemID, UUID pAvatarID) : base(MsgType.Attach, pRegionContext) { PrimID = pPrimID; ItemID = pItemID; AvatarID = pAvatarID; }
public override bool ConvertOut(RegionSyncModule pRegionContext) { lock (m_dataLock) { if (Dir == Direction.Out && DataMap == null) { DataMap = PrepareChatArgs(ChatMessage); } } return base.ConvertOut(pRegionContext); }
public override bool ConvertOut(RegionSyncModule pRegionContext) { lock (m_dataLock) { if (Dir == Direction.Out && DataMap == null) { OSDMap data = new OSDMap(); data["actorID"] = ActorID; DataMap = data; } } return base.ConvertOut(pRegionContext); }
public override bool HandleIn(RegionSyncModule pRegionContext) { if (base.HandleIn(pRegionContext)) { ConnectorContext.otherSideActorID = ActorID; if (pRegionContext.IsSyncRelay) { SyncMsgActorID msg = new SyncMsgActorID(pRegionContext, pRegionContext.ActorID); msg.ConvertOut(pRegionContext); ConnectorContext.ImmediateOutgoingMsg(msg); } } return true; }
public override bool ConvertIn(RegionSyncModule pRegionContext) { bool ret = false; if (base.ConvertIn(pRegionContext)) { ActorID = DataMap["actorID"]; ret = true; } else { ActorID = "UNKNOWN"; } return ret; }
public override bool HandleIn(RegionSyncModule pRegionContext) { if (base.HandleIn(pRegionContext)) { ArrayList errors = new ArrayList(); if (PrimID != UUID.Zero) { SceneObjectPart sop = pRegionContext.Scene.GetSceneObjectPart(PrimID); if (sop != null) { TaskInventoryItem taskItem = sop.Inventory.GetInventoryItem(ItemID); taskItem.AssetID = AssetID; sop.ParentGroup.UpdateInventoryItem(taskItem); if (IsRunning) { // Scripts are recreated when edited so replace the new script inventory item sop.Inventory.RemoveScriptInstance(ItemID, false); sop.Inventory.CreateScriptInstance(ItemID, 0, false, pRegionContext.Scene.DefaultScriptEngine, 0); errors = sop.Inventory.GetScriptErrors(ItemID); } sop.ParentGroup.ResumeScripts(); if (errors.Count > 0) { m_log.ErrorFormat("{0} Script errors detected. TODO: Send errors back to actor that created script", LogHeader); } //trigger the event in the local scene pRegionContext.RememberLocallyGeneratedEvent(MsgType.UpdateScript, AgentID, ItemID, PrimID, IsRunning, AssetID); pRegionContext.Scene.EventManager.TriggerUpdateScript(AgentID, ItemID, PrimID, IsRunning, AssetID); pRegionContext.ForgetLocallyGeneratedEvent(); } } } return true; }
public override bool ConvertOut(RegionSyncModule pRegionContext) { lock (m_dataLock) { if (Dir == Direction.Out && DataMap == null) { OSDMap data = new OSDMap(5 + 2); data["agentID"] = OSD.FromUUID(AgentID); data["itemID"] = OSD.FromUUID(ItemID); data["primID"] = OSD.FromUUID(PrimID); data["running"] = OSD.FromBoolean(IsRunning); data["assetID"] = OSD.FromUUID(AssetID); DataMap = data; } } return base.ConvertOut(pRegionContext); }
public SyncMsgChatFromWorld(RegionSyncModule pRegionContext, OSChatMessage pChatMessage) : base(MsgType.ChatFromWorld, pRegionContext) { ChatMessage = pChatMessage; }
public override bool ConvertIn(RegionSyncModule pRegionContext) { bool ret = false; if (base.ConvertIn(pRegionContext)) { PrimID = DataMap["primID"].AsUUID(); ItemID = DataMap["itemID"].AsUUID(); AvatarID = DataMap["avatarID"].AsUUID(); ret = true; } return ret; }
public override bool ConvertIn(RegionSyncModule pRegionContext) { bool ret = false; if (base.ConvertIn(pRegionContext)) { ChatMessage = PrepareOnChatArgs(DataMap, pRegionContext); ret = true; } return ret; }
public override bool ConvertOut(RegionSyncModule pRegionContext) { lock (m_dataLock) { if (Dir == Direction.Out && DataMap == null) { OSDMap data = new OSDMap(3 + 2); data["primID"] = OSD.FromUUID(PrimID); data["itemID"] = OSD.FromUUID(ItemID); data["avatarID"] = OSD.FromUUID(AvatarID); DataMap = data; } } return base.ConvertOut(pRegionContext); }
public override bool HandleIn(RegionSyncModule pRegionContext) { if (base.HandleIn(pRegionContext)) { m_log.DebugFormat("{0} SyncMsgChatFromWorld: {1} : {2}", LogHeader, ChatMessage.From, ChatMessage.Message); pRegionContext.RememberLocallyGeneratedEvent(MsgType.ChatFromWorld, ChatMessage); // Let ChatModule get the event and deliver it to avatars pRegionContext.Scene.EventManager.TriggerOnChatFromWorld(ChatMessage.SenderObject, ChatMessage); pRegionContext.ForgetLocallyGeneratedEvent(); } return true; }
public override bool HandleIn(RegionSyncModule pRegionContext) { if (base.HandleIn(pRegionContext)) { SceneObjectPart part = pRegionContext.Scene.GetSceneObjectPart(PrimID); if (part == null) { m_log.WarnFormat("{0} HandleRemoteEvent_OnAttach: no part with UUID {1} found", LogHeader, PrimID); return false; } uint localID = part.LocalId; pRegionContext.RememberLocallyGeneratedEvent(MsgType.Attach, localID, ItemID, AvatarID); pRegionContext.Scene.EventManager.TriggerOnAttach(localID, ItemID, AvatarID); pRegionContext.ForgetLocallyGeneratedEvent(); } return true; }
public override bool ConvertIn(RegionSyncModule pRegionContext) { bool ret = false; if (base.ConvertIn(pRegionContext)) { //LocalPrims = new List<SceneObjectPart>(); DelinkPrimIDs = new List<UUID>(); BeforeDelinkGroupIDs = new List<UUID>(); AfterDelinkGroups = new List<SceneObjectGroup>(); PrimSyncInfo = new List<Dictionary<UUID, SyncInfoBase>>(); int partCount = DataMap["partCount"].AsInteger(); for (int i = 0; i < partCount; i++) { string partTempID = "part" + i; UUID primID = DataMap[partTempID].AsUUID(); //SceneObjectPart localPart = Scene.GetSceneObjectPart(primID); //localPrims.Add(localPart); DelinkPrimIDs.Add(primID); } int beforeGroupCount = DataMap["beforeGroupsCount"].AsInteger(); for (int i = 0; i < beforeGroupCount; i++) { string groupTempID = "beforeGroup" + i; UUID beforeGroupID = DataMap[groupTempID].AsUUID(); BeforeDelinkGroupIDs.Add(beforeGroupID); } int afterGroupsCount = DataMap["afterGroupsCount"].AsInteger(); for (int i = 0; i < afterGroupsCount; i++) { string groupTempID = "afterGroup" + i; //string sogxml = data[groupTempID].AsString(); SceneObjectGroup afterGroup; OSDMap encodedSOG = (OSDMap)DataMap[groupTempID]; Dictionary<UUID, SyncInfoBase> groupSyncInfo; if (!DecodeSceneObject(encodedSOG, out afterGroup, out groupSyncInfo, pRegionContext.Scene)) { m_log.WarnFormat("{0}: Failed to decode scene object in HandleSyncDelinkObject", LogHeader); return false; } AfterDelinkGroups.Add(afterGroup); PrimSyncInfo.Add(groupSyncInfo); } ret = true; } return ret; }
public SyncInfoManager(RegionSyncModule syncModule, long ageOutTh) { m_syncedUUIDs = new Dictionary <UUID, SyncInfoBase>(); m_regionSyncModule = syncModule; m_ageOutThreshold = ageOutTh; }
public override void LogReception(RegionSyncModule pRegionContext, SyncConnector pConnectorContext) { // This override is here so the reception will not be default logged and the actual logging can occur // after the properties have been processed. }
public SyncMsgUpdateScript(RegionSyncModule pRegionContext, UUID pAgentID, UUID pItemID, UUID pPrimID, bool pIsRunning, UUID pAssetID) : base(MsgType.UpdateScript, pRegionContext) { AgentID = pAgentID; ItemID = pItemID; PrimID = pPrimID; IsRunning = pIsRunning; AssetID = pAssetID; }
public override bool ConvertOut(RegionSyncModule pRegionContext) { lock (m_dataLock) { if (Dir == Direction.Out && DataMap == null) { DataMap = pRegionContext.InfoManager.EncodeProperties(Uuid, SyncableProperties); if (DataMap == null) return false; // m_log.DebugFormat("{0} SyncMsgUpdatedProperties.ConvertOut, syncProp={1}, DataMap={2}", LogHeader, SyncableProperties, DataMap); } } return base.ConvertOut(pRegionContext); }
public override void LogReception(RegionSyncModule pRegionContext, SyncConnector pConnectorContext) { if (RegionContext != null) RegionContext.DetailedUpdateWrite(DetailLogTagRcv, AvatarID, 0, ZeroUUID, pConnectorContext.otherSideActorID, DataLength); }
public SyncMsgActorID(RegionSyncModule pRegionContext, string pActorID) : base(MsgType.ActorID, pRegionContext) { ActorID = pActorID; }
//TODO: might return status such as Updated, Unchanged, etc to caller public HashSet <SyncableProperties.Type> UpdatePropertiesBySync(UUID uuid, HashSet <SyncedProperty> syncedProperties) { long recvTS = RegionSyncModule.NowTicks(); HashSet <SyncableProperties.Type> propertiesUpdated = new HashSet <SyncableProperties.Type>(); List <SyncedProperty> updatedSyncedProperties = new List <SyncedProperty>(); lock (m_syncLock) { foreach (SyncedProperty syncedProperty in syncedProperties) { bool updated = false; SyncableProperties.Type property = syncedProperty.Property; //Compare if the value of the property in this SyncInfo is different than the value in local scene SyncedProperty currentlySyncedProperty; CurrentlySyncedProperties.TryGetValue(property, out currentlySyncedProperty); // If synced property is not in cache, add it now. if (currentlySyncedProperty == null) { //could happen if PhysActor is just created (object stops being phantom) if (SyncableProperties.PhysActorProperties.Contains(property)) { CurrentlySyncedProperties.Add(property, syncedProperty); } else { DebugLog.WarnFormat("{0}: UpdatePropertiesBySync: No record of property {1} for uuid {2}", LogHeader, property, uuid); } } else { try { //Compare timestamp and update SyncInfo if necessary updated = currentlySyncedProperty.CompareAndUpdateSyncInfoBySync(syncedProperty, recvTS); //If updated, update the property value in scene object/presence if (updated) { //SetPropertyValue(property); updatedSyncedProperties.Add(currentlySyncedProperty); propertiesUpdated.Add(property); } } catch (Exception e) { DebugLog.ErrorFormat("{0}: UpdatePropertiesBySync: Error in updating property {1}: {2}", LogHeader, property, e.Message); } } } } //Now we only need to read from the SyncInfo, so moving the SetPropertyValue out of lock, to avoid potential deadlocks //which might happen due to side effects of "set" functions of a SOp or SP property foreach (SyncedProperty updatedProperty in updatedSyncedProperties) { SetPropertyValue(updatedProperty); } PostUpdateBySync(propertiesUpdated); return(propertiesUpdated); }
public SyncMsgChatBroadcast(RegionSyncModule pRegionContext, OSChatMessage pChatMessage) : base(MsgType.ChatBroadcast, pRegionContext) { ChatMessage = pChatMessage; }
public override bool HandleIn(RegionSyncModule pRegionContext) { if (base.HandleIn(pRegionContext)) { m_log.DebugFormat("{0} SyncMsgChatBroadcast: {1} : {2}", LogHeader, ChatMessage.From, ChatMessage.Message); pRegionContext.RememberLocallyGeneratedEvent(MsgType.ChatBroadcast, ChatMessage); pRegionContext.Scene.EventManager.TriggerOnChatBroadcast(ChatMessage.SenderObject, ChatMessage); pRegionContext.ForgetLocallyGeneratedEvent(); } return true; }
public override bool ConvertIn(RegionSyncModule pRegionContext) { bool ret = false; if (base.ConvertIn(pRegionContext)) { ret = true; // Decode synced properties from the message. never null. SyncedProperties = SyncInfoBase.DecodeSyncedProperties(DataMap); Uuid = DataMap["uuid"].AsUUID(); } else { m_log.ErrorFormat("{0} UpdatedProperties.ConvertIn failed to convert input data", LogHeader); ret = false; } return ret; }