// Add this DistributedObject to the repository. public void AddObject(IDistributedObject obj) { DistributedObjectId doId = obj.DistributedObjectId; // Store in the dictionary of objects mObjectIds[doId] = obj; }
/// <summary> /// Returns the object referenced by the doId or null if not found on this state server. /// </summary> /// <param name="doId"></param> /// <returns></returns> public IDistributedObject GetObject(DistributedObjectId doId) { IDistributedObject obj = null; mObjectIds.TryGetValue(doId, out obj); return(obj); }
public void DeleteObjectMessage(bool broadcastMessage, DistributedObjectId distributedObjectId, List <object> data) { mBroadcast = broadcastMessage; mDistributedObjectId = distributedObjectId; mData = data; mMessageType = MessageType.Delete; }
public void CreateObjectMessage(bool broadcastMessage, bool storeInRam, DistributedObjectId distributedObjectId, List <object> data) { mBroadcast = broadcastMessage; mStoreInRam = storeInRam; mDistributedObjectId = distributedObjectId; mData = data; mMessageType = MessageType.Create; }
//The first argument in List<object>data will contain all the serializable data we want //Eg: Data = new List<object> ( float x, float y, float z, float x, float y, float z, float w ); public void UpdateObjectMessage(bool broadcastMessage, bool storeInRam, DistributedObjectId distributedObjectId, int callback, List <object> data) { mBroadcast = broadcastMessage; mStoreInRam = storeInRam; mDistributedObjectId = distributedObjectId; mCallback = callback; mData = data; mMessageType = MessageType.Update; }
public Message(SerializationInfo info, StreamingContext ctxt) : this() { mBroadcast = info.GetBoolean("broadcast"); mStoreInRam = info.GetBoolean("storeInRam"); mDistributedObjectId = (DistributedObjectId)info.GetValue("objectId", typeof(DistributedObjectId));//info.GetUInt32("objectId"); mCallback = info.GetInt32("callback"); mData = (List <object>)info.GetValue("data", typeof(List <object>)); mMessageType = (MessageType)info.GetValue("messageType", typeof(MessageType)); mId = info.GetInt32("id"); }
// Remove this DistributedObject from the repository. public virtual void RemoveObject(IDistributedObject obj) { // Remove from object id dict DistributedObjectId doId = obj.DistributedObjectId; if (!mObjectIds.Remove(doId)) { Console.WriteLine("Warning!!! We don't have this object!"); return; } }
// Returns true if this state server currently is maintaining this object in memory. public bool ContainsObject(DistributedObjectId doId) { return(mObjectIds.ContainsKey(doId)); }
public DistributedObject(DistributedObjectId doId) { mDistributedObjectId = doId; RegisterMessageActions(); }