void controller_ObjectCreated(object source, ObjectCreatedArgs e)
        {
            if (this.rpc.IsServer)
            {
                LogFile.WriteLine("netreplicationcontroller,server ObjectCreated " + e.TargetObject.GetType());
                //LogFile.WriteLine("controller_ObjectCreated() " + e.TargetObject);
                //NetworkInterfaces.ObjectReplicationServerToClient_ClientProxy objectreplicationproxy = new OSMP.NetworkInterfaces.ObjectReplicationServerToClient_ClientProxy( rpc,
                // handled by something like DirtyCacheController
                dirtyobjectcontroller.MarkDirty(e.TargetObject, new Type[] { typeof(Replicate) });
            }
            else
            {
                LogFile.WriteLine("netreplicationcontroller,client ObjectCreated " + e.TargetObject.GetType());
                int tempreference = GenerateTempReference();
                tempreferences.Add(tempreference, e.TargetObject);

                Type[] AttributeTypeList = new Type[] { typeof(Replicate) };
                int    bitmap            = new ReplicateAttributeHelper().TypeArrayToBitmap(AttributeTypeList);

                byte[] entitydata   = new byte[4096];
                int    nextposition = 0;
                new BinaryPacker().PackObjectUsingSpecifiedAttributes(entitydata, ref nextposition,
                                                                      e.TargetObject, AttributeTypeList);

                byte[] entitydatatotransmit = new byte[nextposition];
                Buffer.BlockCopy(entitydata, 0, entitydatatotransmit, 0, nextposition);

                //LogFile.WriteLine(Encoding.UTF8.GetString(entitydatatotransmit));

                NetworkInterfaces.ObjectReplicationClientToServer_ClientProxy objectreplicationproxy = new OSMP.NetworkInterfaces.ObjectReplicationClientToServer_ClientProxy(rpc, null);
                objectreplicationproxy.ObjectCreated(tempreference, e.TargetObject.GetType().ToString(), bitmap, entitydatatotransmit);
            }
        }
Ejemplo n.º 2
0
        // incoming event from NetReplicationController:
        void IReplicatedObjectController.ReplicatedObjectCreated(object notifier, ObjectCreatedArgs e)
        {
            LogFile.WriteLine("WorldModel ReplicatedObjectCreated " + e.TargetObject);
            Entity newentity = e.TargetObject as Entity;

            entities.Add(newentity);
            entitybyreference.Add(newentity.iReference, newentity);
            //if(this.ObjectCreated != null )
            //{
            //  ObjectCreated( this, new ObjectCreatedArgs( DateTime.Now, newentity ) );
            //}
            if (AfterCreate != null)
            {
                AfterCreate(this, new CreateEntityEventArgs(newentity));
            }
        }
Ejemplo n.º 3
0
 // incoming event from NetReplicationController:
 void IReplicatedObjectController.ReplicatedObjectCreated(object notifier, ObjectCreatedArgs e)
 {
     LogFile.WriteLine("WorldModel ReplicatedObjectCreated " + e.TargetObject);
     Entity newentity = e.TargetObject as Entity;
     entities.Add( newentity );
     entitybyreference.Add(newentity.iReference, newentity);
     //if(this.ObjectCreated != null )
     //{
       //  ObjectCreated( this, new ObjectCreatedArgs( DateTime.Now, newentity ) );
     //}
     if (AfterCreate != null)
     {
         AfterCreate(this, new CreateEntityEventArgs(newentity));
     }
 }
        void controller_ObjectCreated(object source, ObjectCreatedArgs e)
        {
            if( this.rpc.IsServer )
            {
                LogFile.WriteLine("netreplicationcontroller,server ObjectCreated " + e.TargetObject.GetType());
                //LogFile.WriteLine("controller_ObjectCreated() " + e.TargetObject);
                //NetworkInterfaces.ObjectReplicationServerToClient_ClientProxy objectreplicationproxy = new OSMP.NetworkInterfaces.ObjectReplicationServerToClient_ClientProxy( rpc,
                // handled by something like DirtyCacheController
                dirtyobjectcontroller.MarkDirty(e.TargetObject, new Type[] { typeof(Replicate) });
            }
            else
            {
                LogFile.WriteLine("netreplicationcontroller,client ObjectCreated " + e.TargetObject.GetType());
                int tempreference = GenerateTempReference();
                tempreferences.Add( tempreference, e.TargetObject );

                Type[] AttributeTypeList = new Type[] { typeof(Replicate) };
                int bitmap = new ReplicateAttributeHelper().TypeArrayToBitmap( AttributeTypeList );

                byte[] entitydata = new byte[4096];
                int nextposition = 0;
                new BinaryPacker().PackObjectUsingSpecifiedAttributes(entitydata, ref nextposition,
                    e.TargetObject, AttributeTypeList);

                byte[]entitydatatotransmit = new byte[ nextposition ];
                Buffer.BlockCopy( entitydata,0, entitydatatotransmit, 0, nextposition );

                //LogFile.WriteLine(Encoding.UTF8.GetString(entitydatatotransmit));

                NetworkInterfaces.ObjectReplicationClientToServer_ClientProxy objectreplicationproxy = new OSMP.NetworkInterfaces.ObjectReplicationClientToServer_ClientProxy(rpc, null);
                objectreplicationproxy.ObjectCreated(tempreference, e.TargetObject.GetType().ToString(), bitmap, entitydatatotransmit );
            }
        }