Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xmpp-pane
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Adrien Dorsaz
xmpp-pane
Commits
05c9f2cc
Commit
05c9f2cc
authored
Mar 28, 2018
by
Adrien Dorsaz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
entity: update to use Map
parent
0bb2edcb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
29 deletions
+15
-29
src/xmpp/discover/entity.js
src/xmpp/discover/entity.js
+15
-29
No files found.
src/xmpp/discover/entity.js
View file @
05c9f2cc
...
...
@@ -8,48 +8,34 @@
* [XEP-0030](https://xmpp.org/extensions/xep-0030.html)
*/
class
Entity
{
constructor
()
{
this
.
identities
=
[];
constructor
(
_jid
)
{
this
.
jid
=
_id
;
// Services supported by the Entity
// key: category and type of the identity
// value: identity name
this
.
identities
=
new
Map
();
// Features and protocols supported by the entity
this
.
features
=
[]
;
this
.
protocols
=
{}
;
this
.
features
=
new
Map
()
;
this
.
protocols
=
new
Map
()
;
}
/*
* _identity is a <identity> XML Node
* _xmllang is the client preerend language
*/
addIdentity
(
_identity
,
_xmllang
)
{
addIdentity
(
_identity
)
{
let
type
=
_identity
.
getAttribute
(
'
type
'
);
let
category
=
_identity
.
getAttribute
(
'
category
'
);
let
xmllang
=
_identity
.
getAttribute
(
'
xml:lang
'
);
let
name
=
_identity
.
getAttribute
(
'
name
'
);
let
identity
;
let
found
=
false
;
for
(
let
identity
of
this
.
identities
){
if
(
identity
.
type
===
type
&&
identity
.
category
===
category
)
{
found
=
true
;
break
;
}
}
let
idKey
=
[
'
type
'
:
type
,
'
category
'
:
category
];
let
identity
=
this
.
identities
.
get
(
idKey
)
if
(
found
)
{
if
(
xmllang
===
_xmllang
&&
xmllang
!==
identity
.
xmllang
)
{
identity
.
name
=
name
;
identity
.
xmllang
=
xmllang
;
}
if
(
identity
)
{
identity
=
name
;
}
else
{
this
.
identities
.
add
({
'
type
'
:
type
,
'
category
'
:
category
,
'
xmllang
'
:
xmllang
,
'
name
'
:
name
});
this
.
identities
.
set
(
idKey
,
name
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment