Exemple #1
0
        private ChildAgentUpdate2Response SendChildAgentUpdate2()
        {
            ScenePresence        agent            = _avatar.ScenePresence;
            SceneObjectGroup     sceneObjectGroup = _avatar.TransitArgs.RideOnGroup;
            SceneObjectPart      part             = _avatar.TransitArgs.RideOnPart;
            ulong                newRegionHandle  = _avatar.TransitArgs.DestinationRegion.RegionHandle;
            SimpleRegionInfo     neighbourRegion  = _avatar.TransitArgs.DestinationRegion;
            Vector3              pos             = _avatar.TransitArgs.LocationInDestination;
            AgentLocomotionFlags locomotionFlags = 0;

            if (_avatar.TransitArgs.Type == TransitType.OutboundCrossing)
            {
                locomotionFlags = AgentLocomotionFlags.Crossing;
            }
            else if (_avatar.TransitArgs.Type == TransitType.OutboundTeleport)
            {
                locomotionFlags = AgentLocomotionFlags.Teleport;
            }

            AgentData cAgent = new AgentData();

            agent.CopyToForRootAgent(cAgent);

            if (part == null)
            {
                cAgent.Position = pos;
            }

            cAgent.LocomotionState = 1;
            cAgent.LocomotionFlags = locomotionFlags;

            List <SceneObjectGroup> attachments = agent.CollectAttachmentsForCrossing();

            //try the new comms first
            var engine = ProviderRegistry.Instance.Get <ISerializationEngine>();

            if (engine == null)
            {
                _log.ErrorFormat("[SCENE COMM]: Cannot send child agent update to {0}, Serialization engine is missing!",
                                 neighbourRegion.RegionHandle);
                return(ChildAgentUpdate2Response.Error);
            }

            List <byte[]> serializedAttachments = new List <byte[]>();

            foreach (var att in attachments)
            {
                //mark the SOG in-transit. this along with the serialization below sends a disable to the script engine, but they are not cumulative
                att.StartTransit();

                //we are stopping the scripts as part of the serialization process here
                //this means that later on, should the remote creation call fail, we need to re-enable them
                //reenabling is done via EndTransit with success==false
                byte[] sogBytes = engine.SceneObjectSerializer.SerializeGroupToBytes(att, SerializationFlags.FromCrossing | SerializationFlags.StopScripts | SerializationFlags.SerializeScriptBytecode);
                serializedAttachments.Add(sogBytes);
            }

            cAgent.SerializedAttachments = serializedAttachments;

            var scene = agent.Scene;

            cAgent.CallbackURI = scene.RegionInfo.InsecurePublicHTTPServerURI +
                                 "/agent/" + agent.UUID.ToString() + "/" + agent.Scene.RegionInfo.RegionHandle.ToString() + "/release/";

            ChildAgentUpdate2Response resp = scene.InterregionComms.SendChildAgentUpdate2(neighbourRegion, cAgent);

            if (resp == ChildAgentUpdate2Response.Error)
            {
                _log.ErrorFormat("[SCENE COMM]: Error sending child agent update to {0}", neighbourRegion.RegionHandle);
            }
            else if (resp == ChildAgentUpdate2Response.MethodNotAvailalble)
            {
                _log.ErrorFormat("[SCENE COMM]: Error sending child agent update to {0}, ChildAgentUpdate2 not available. Falling back to old method", neighbourRegion.RegionHandle);
            }

            return(resp);
        }