private void Publish() { UccOperationContext operationContext = new UccOperationContextClass(); operationContext.Initialize(0, new UccContextClass()); IUccPublicationManager publicationManager = (IUccPublicationManager)this.endpoint; IUccCategoryInstance categoryInstance = null; //this.selfPresentity.CreatePublishableStateCategoryInstance(); if (categoryInstance == null) { categoryInstance = publicationManager.CreatePublishableCategoryInstance( CategoryName.State, 2, 0, UCC_CATEGORY_INSTANCE_EXPIRE_TYPE.UCCCIET_DEVICE, 0); operationContext.Context.AddProperty(ContextInitialPublication, true); } categoryInstance.PublicationOperation = UCC_PUBLICATION_OPERATION_TYPE.UCCPOT_ADD; IUccPresenceStateInstance stateInstance = (IUccPresenceStateInstance)categoryInstance; stateInstance.Availability = (int)this.SelfPresentity.Availability; stateInstance.Type = UCC_PRESENCE_STATE_TYPE.UCCPST_USER_STATE; IUccPublication publication = publicationManager.CreatePublication(); ComEvents.Advise <_IUccPublicationEvent>(publication, this); publication.AddPublishableCategoryInstance(categoryInstance); publication.Publish(operationContext); }
public void PublishAvailability(string strAvail) { // Create a publishable category instance for the "state" // category to publish the user state. This is indicated by // setting the Type to "machinestate". The availability for // userState is set to the availability specifed by // the user. IUccPublicationManager publicationManager = this._sessionManager as IUccPublicationManager; IUccCategoryInstance catStateForUserState = publicationManager.CreatePublishableCategoryInstance( "state", // category name 2, // container ID 0x20000000, // instance ID UCC_CATEGORY_INSTANCE_EXPIRE_TYPE.UCCCIET_USER, 0); IUccPresenceStateInstance userState = catStateForUserState as IUccPresenceStateInstance; userState.IsManual = true; userState.Type = UCC_PRESENCE_STATE_TYPE.UCCPST_USER_STATE; //Convert availablity string to integer for publication userState.Availability = AvailabilityStringToInt(strAvail); catStateForUserState.PublicationOperation = UCC_PUBLICATION_OPERATION_TYPE.UCCPOT_ADD; // Create a publishable category instance for "state" // category to publish the machine state. // This is indicated by setting the Type to "machinestate". // The availability for machinestate is set to 3500 - "Available". // The server aggregates the userstate and machinestate // to compute an aggregate state which is then // published on behalf of the user. It is important to // publish machinestate to make this aggregation possible. IUccCategoryInstance catStateForMachineState = publicationManager.CreatePublishableCategoryInstance( "state", 2, 0x30000000, UCC_CATEGORY_INSTANCE_EXPIRE_TYPE.UCCCIET_DEVICE, 10000); IUccPresenceStateInstance machineState = catStateForMachineState as IUccPresenceStateInstance; machineState.IsManual = true; machineState.Availability = 3500; machineState.Type = UCC_PRESENCE_STATE_TYPE.UCCPST_MACHINE_STATE; catStateForMachineState.PublicationOperation = UCC_PUBLICATION_OPERATION_TYPE.UCCPOT_ADD; // Create a publication and advise for publication events. IUccPublication pub = publicationManager.CreatePublication(); //Advise<_IUccPublicationEvent>(pub, this); // Add the two publishable category instances // to the publication. pub.AddPublishableCategoryInstance( catStateForUserState); pub.AddPublishableCategoryInstance( catStateForMachineState); // Publish the publication. pub.Publish(null); }