private void UpdateOthersWithOwnData() { var updateState = new MyStateContainer { StateDictionary = new Dictionary <Guid, MyUserUpdateState>(1) }; updateState.StateDictionary.Add(id, UserState); SyncManager.Update(updateState); //example to update neighbors only //syncManager.Update(updateState,true); //example to update by specified hop count //syncManager.Update(updateState, 111); }
static void Main(string[] args) { MyTracingHost host = new MyTracingHost(typeof(ZipCodeService)); MyStateContainer sc = new MyStateContainer("foo"); host.Extensions.Add(sc); try { host.Open(); Console.WriteLine("ZipCodeService is running. Press any key to exit."); Console.ReadKey(); host.Close(); // successful close } catch (Exception ex) { Console.WriteLine(ex); host.Abort(); } }
/// <summary> /// Generate BusinessLogicMessageBase message that will be returned back to the mesh based on given synchronizationRequest with FullDetailedResponse set to true /// should override to produce application specific response /// </summary> /// <param name="synchronizationDetailsRequest">the detailed request received from the mesh contain the id's that should respond with full details (partial detailed response)</param> /// <returns>BusinessLogicMessageBase instance or null if don't want to response</returns> BusinessLogicMessageBase ISynchronizationBusinessLogic.ProvideSynchronizationDetailResponse(BusinessLogicMessageBase synchronizationDetailsRequest) { #if DEBUG LogManager.GetCurrentClassLogger().Debug("ProvideSynchronizationDetailResponse: {0}", synchronizationDetailsRequest); #endif if (synchronizationDetailsRequest is MyKeysStateIdsContainer) { var myKeysStateResponse = synchronizationDetailsRequest as MyKeysStateIdsContainer; lock (syncLock) { //Filter the response to contain only the keys requested var filtered = from myUserUpdateState in MyStateDictionary where myKeysStateResponse.StateIds.Contains(myUserUpdateState.Key) select myUserUpdateState; var response = new MyStateContainer { StateDictionary = filtered.ToDictionary(x => x.Key, x => x.Value) }; return(response); } } return(null); }