예제 #1
0
        // Given an incoming stream of bytes, create a SyncMsg from the next data on that stream.
        // The input stream should contain:
        //      4 bytes: the msgType code
        //      4 bytes: number of bytes following for the message data
        //      N bytes: the data for this type of messsage
        public static SyncMsg SyncMsgFactory(Stream pStream, SyncConnector pConnectorContext)
        {
            SyncMsg ret = null;

            MsgType mType = (MsgType)Utils.BytesToInt(GetBytesFromStream(pStream, 4));
            int length = Utils.BytesToInt(GetBytesFromStream(pStream, 4));
            byte[] data = GetBytesFromStream(pStream, length);

            switch (mType)
            {
            case MsgType.UpdatedProperties: ret = new SyncMsgUpdatedProperties(length, data);    break;
            case MsgType.GetTerrain:        ret = new SyncMsgGetTerrain(length, data);           break;
            case MsgType.GetObjects:        ret = new SyncMsgGetObjects(length, data);           break;
            case MsgType.GetPresences:      ret = new SyncMsgGetPresences(length, data);         break;
            case MsgType.GetRegionInfo:     ret = new SyncMsgGetRegionInfo(length, data);        break;
            case MsgType.GetEnvironment:    ret = new SyncMsgGetEnvironment(length, data);       break;
            case MsgType.Terrain:           ret = new SyncMsgTerrain(length, data);              break;
            case MsgType.RegionInfo:        ret = new SyncMsgRegionInfo(length, data);           break;
            case MsgType.Environment:       ret = new SyncMsgEnvironment(length, data);          break;
            case MsgType.NewObject:         ret = new SyncMsgNewObject(length, data);            break;
            case MsgType.RemovedObject:     ret = new SyncMsgRemovedObject(length, data);        break;
            case MsgType.LinkObject:        ret = new SyncMsgLinkObject(length, data);           break;
            case MsgType.DelinkObject:      ret = new SyncMsgDelinkObject(length, data);         break;
            case MsgType.NewPresence:       ret = new SyncMsgNewPresence(length, data);          break;
            case MsgType.RemovedPresence:   ret = new SyncMsgRemovedPresence(length, data);      break;
            case MsgType.RegionName:        ret = new SyncMsgRegionName(length, data);           break;
            case MsgType.ActorID:           ret = new SyncMsgActorID(length, data);              break;
            case MsgType.RegionStatus:      ret = new SyncMsgRegionStatus(length, data);         break;

            case MsgType.NewScript:         ret = new SyncMsgNewScript(length, data);            break;
            case MsgType.UpdateScript:      ret = new SyncMsgUpdateScript(length, data);         break;
            case MsgType.ScriptReset:       ret = new SyncMsgScriptReset(length, data);          break;
            case MsgType.ChatFromClient:    ret = new SyncMsgChatFromClient(length, data);       break;
            case MsgType.ChatFromWorld:     ret = new SyncMsgChatFromWorld(length, data);        break;
            case MsgType.ChatBroadcast:     ret = new SyncMsgChatBroadcast(length, data);        break;
            case MsgType.ObjectGrab:        ret = new SyncMsgObjectGrab(length, data);           break;
            case MsgType.ObjectGrabbing:    ret = new SyncMsgObjectGrabbing(length, data);       break;
            case MsgType.ObjectDeGrab:      ret = new SyncMsgObjectDeGrab(length, data);         break;
            case MsgType.Attach:            ret = new SyncMsgAttach(length, data);               break;

            // case MsgType.PhysicsCollision:      ret = new SyncMsgPhysicsCollision(length, data);     break;
            case MsgType.ScriptCollidingStart:  ret = new SyncMsgScriptCollidingStart(length, data); break;
            case MsgType.ScriptColliding:       ret = new SyncMsgScriptColliding(length, data);      break;
            case MsgType.ScriptCollidingEnd:    ret = new SyncMsgScriptCollidingEnd(length, data);   break;
            case MsgType.ScriptLandCollidingStart:ret = new SyncMsgScriptLandCollidingStart(length, data);   break;
            case MsgType.ScriptLandColliding:   ret = new SyncMsgScriptLandColliding(length, data);  break;
            case MsgType.ScriptLandCollidingEnd:ret = new SyncMsgScriptLandCollidingEnd(length, data);   break;

            case MsgType.TimeStamp:         ret = new SyncMsgTimeStamp(length, data);            break;
            // case MsgType.UpdatedBucketProperties: ret = new SyncMsgUpdatedBucketProperties(length, data); break;

            case MsgType.KeepAlive: ret = new SyncMsgKeepAlive(length, data); break;
            default:
                m_log.ErrorFormat("{0}: Unknown Sync Message Type {1}", LogHeader, mType);
                break;
            }

            if (ret != null)
            {
            ret.ConnectorContext = pConnectorContext;
            }

            return ret;
        }
예제 #2
0
 public override bool HandleIn(RegionSyncModule pRegionContext)
 {
     if (base.HandleIn(pRegionContext))
     {
     EntityBase[] entities = pRegionContext.Scene.GetEntities();
     foreach (EntityBase e in entities)
     {
         ScenePresence sp = e as ScenePresence;
         if (sp != null)
         {
             // This will sync the appearance that's currently in the agent circuit data.
             // If the avatar has updated their appearance since they connected, the original data will still be in ACD.
             // The ACD normally only gets updated when an avatar is moving between regions.
             SyncMsgNewPresence msg = new SyncMsgNewPresence(pRegionContext, sp);
             msg.ConvertOut(pRegionContext);
             // m_log.DebugFormat("{0}: Send NewPresence message for {1} ({2})", LogHeader, sp.Name, sp.UUID);
             ConnectorContext.ImmediateOutgoingMsg(msg);
         }
     }
     }
     return true;
 }