private void SendObjectInsertedPayload(ObjectInsertedPayload data) { // Add to pending list CollectionOperation change = new CollectionOperation(data); this.LocalOperations.Add(change); this.client.SendPublishEvent(data); }
override internal void OnObjectInserted(ObjectInsertedPayload data) { if (data.ClientId == this.client.ClientId) { Debug.Assert(UnackedMessages > 0); --UnackedMessages; return; } BaseOnObjectInserted(data); }
private void OnObjectInserted(ObjectInsertedPayload data) { CollectionEntry collectionEntry; if (!this.client.CollectionsManager.TryGetValue(data.Parent.Id, out collectionEntry)) { Debug.WriteLine("Missing collection for incoming object insertion"); return; } // Route insert request to the collection entry collectionEntry.OnObjectInserted(data); }
private void AddSharedObjects(IList items) { Debug.Assert(client.CheckAccess()); foreach (INotifyPropertyChanged addedObj in items) { ObjectEntry objectEntry; if (AddSharedObject(addedObj, -1, out objectEntry)) { Debug.WriteLine(string.Format("[UnorderedCollection] - Client={0}: LOCAL Inserting {1}", this.client.ClientId, objectEntry.Object)); var payload = new ObjectInsertedPayload(this.Id, objectEntry.Id, this.client.ClientId); SendObjectInsertedPayload(payload); } } }
private void AddSharedObjects(IList items) { Debug.Assert(client.CheckAccess()); foreach (INotifyPropertyChanged addedObj in items) { int index = this.GetMasterCollection().IndexOf(addedObj); ObjectEntry objectEntry; if (AddSharedObject(addedObj, index, out objectEntry)) { this.CollectionIndices.Insert(index, objectEntry.Id); Debug.WriteLine(string.Format("[OrderedCollection] - Client={0}: LOCAL Inserting {1} in position {2}", this.client.ClientId, objectEntry.Object, index)); var payload = new ObjectInsertedPayload(this.Id, objectEntry.Id, index, this.OperationSequence, this.client.ClientId); SendObjectInsertedPayload(payload); } } }
override internal void OnObjectInserted(ObjectInsertedPayload data) { Debug.Assert(this.IsConnected == false || this.OperationSequence == 0 || data.OperationSequence == this.OperationSequence + 1); this.OperationSequence = data.OperationSequence; // Check if this is a locally pending insert, if so remove the insert from the list of LocalOperations if (data.ClientId == this.client.ClientId) { this.ProcessAck(OperationAction.Insert, data.ObjectId); return; } // Apply transformation, update index CollectionOperation operation = new CollectionOperation(data); this.ApplyTransform(this, ref operation); data.Parent.Index = operation.ObjectIndex; if (operation.ApplyOperation) { BaseOnObjectInserted(data); } }
protected void BaseOnObjectInserted(ObjectInsertedPayload data) { ObjectEntry objectEntry; if (!this.client.ObjectsManager.TryGetValue(data.ObjectId, out objectEntry)) { Debug.Assert(false, "Missing object for incoming object insertion"); return; } Debug.Assert(client.CheckAccess()); Debug.Assert(!this.Items.ContainsKey(data.ObjectId), "Cannot re-insert object with same ID as existing object"); objectEntry.AddParent(data.Parent); try { objectEntry.IgnoreChanges = true; if (this.Items.ContainsKey(objectEntry.Id)) { // TODO: this can happen due to a race condition Debug.Assert(false, "Trying to add object to collection it already contains"); } else { this.Items.Add(objectEntry.Id, objectEntry); AddObjectToCollection(data, objectEntry); Debug.WriteLine(string.Format("[OrderedCollection] - Client={0}: REMOTE Inserting {1} in position {2}", this.client.ClientId, objectEntry.Object, data.Parent.Index)); } } finally { objectEntry.IgnoreChanges = false; } }
public CollectionOperation(ObjectInsertedPayload data) : this(data as CollectionChangedPayload) { this.Action = OperationAction.Insert; }
protected override void AddObjectToCollection(ObjectInsertedPayload data, ObjectEntry objectEntry) { this.GetMasterCollection().IncomingInsert(data.Parent.Index, objectEntry.Object); this.CollectionIndices.Insert(data.Parent.Index, objectEntry.Id); }
private void SendObjectInsertedPayload(ObjectInsertedPayload data) { this.client.SendPublishEvent(data); ++UnackedMessages; }
protected override void AddObjectToCollection(ObjectInsertedPayload data, ObjectEntry objectEntry) { this.GetMasterCollection().IncomingAdd(objectEntry.Object); }
abstract protected void AddObjectToCollection(ObjectInsertedPayload data, ObjectEntry objectEntry);
abstract internal void OnObjectInserted(ObjectInsertedPayload data);