public void receiveUpdate(DatagramIn dg, IDistributedObject distObj, UInt16 field_id)
    {
        Debug.Log("Receive update for class " + distObj.getClass() + " field ID" + field_id);

        // first get the array of fields we'll need to unpack

        string[] t_fields = DCFile.fieldLookup[field_id];

        // next, define an empty array of params the size of the number of fields
        object[] t_params = new object[t_fields.Length];

        // unpack the parameters

        for (int i = 0; i < t_fields.Length; ++i)
        {
            t_params[i] = unserializeType(dg, t_fields[i]);
        }

        // finally, use reflection to call the function
        Type t_type = distObj.GetType();

        MethodInfo t_method = t_type.GetMethod(DCFile.fieldNameLookup[field_id]);

        t_method.Invoke(distObj, t_params);
    }
Ejemplo n.º 2
0
 // Remove this DistributedObject from the repository.
 public override void RemoveObject(IDistributedObject obj)
 {
     if (obj.GetType().IsAssignableFrom(typeof(IServerDistributedObject)))
     {
         // Upcast to server version so we get the extra cleanup
         this.RemoveObject((IServerDistributedObject)obj);
     }
     else
     {
         // Just call the base class version
         base.RemoveObject(obj);
     }
 }