本文整理匯總了TypeScript中@connection/xmpp/namespace.get函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript get函數的具體用法?TypeScript get怎麽用?TypeScript get使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了get函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: addBookmark
private async addBookmark(room: RoomBookmark) {
let storageElement: JQuery<Element>;
try {
storageElement = await this.getBookmarks();
} catch (err) {
storageElement = $('<storage>').attr('xmlns', NS.get('BOOKMARKS'));
}
let roomBareJid = room.getJid().bare;
storageElement.find(`[jid="${roomBareJid}"]`).remove();
let conferenceElement = $('<conference>');
conferenceElement.attr({
name: room.getAlias(),
autojoin: room.isAutoJoin(),
jid: roomBareJid,
});
if (room.hasNickname()) {
let nickElement = $('<nick>');
nickElement.text(room.getNickname());
nickElement.appendTo(conferenceElement);
}
storageElement.append(conferenceElement);
return this.publishBookmarks(storageElement);
}
示例2: publishBookmarks
private publishBookmarks(storageElement: JQuery<Element>) {
let pubSubService = this.connection.getPubSubService();
let item = $build('item', {
id: 'current'
}).cnode(storageElement.get(0));
return pubSubService.publish(NS.get('BOOKMARKS'), item, this.getOptionForm());
}
示例3: getBookmarks
private async getBookmarks(): Promise<JQuery<Element>> {
let pubSubService = this.connection.getPubSubService();
let bookmarkNode = await pubSubService.getAllItems(NS.get('BOOKMARKS'));
let storageElement = $(bookmarkNode).find(NS.getFilter('BOOKMARKS', 'storage'));
if (storageElement.length !== 1) {
throw new Error('Could not retrieve bookmarks.');
}
return storageElement;
}
示例4: getOptionForm
private getOptionForm(): Form {
return Form.fromJSON({
type: 'submit',
fields: [{
type: 'hidden',
name: 'FORM_TYPE',
values: [NS.get('PUBSUB_PUBLISH_OPTIONS')]
}, {
name: 'pubsub#persist_items',
values: ['1']
}, {
name: 'pubsub#access_model',
values: ['whitelist']
}]
});
}