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
db10fe49
Commit
db10fe49
authored
Apr 04, 2018
by
Adrien Dorsaz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
entity - network - client wip
parent
12125bbc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
16 deletions
+31
-16
src/xmpp/client.js
src/xmpp/client.js
+6
-0
src/xmpp/discover/entity.js
src/xmpp/discover/entity.js
+10
-3
src/xmpp/network.js
src/xmpp/network.js
+15
-13
No files found.
src/xmpp/client.js
View file @
db10fe49
...
...
@@ -48,6 +48,10 @@ class Client {
this
.
lastContractId
=
0
;
}
get
network
()
{
return
this
.
xmppNet
;
}
// Promising a contract
promise
(
_message
,
_nodeName
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
...
...
@@ -439,6 +443,8 @@ class Client {
}
console
.
log
(
'
client: discoPubsubService: succeed:
'
+
entity
);
this
.
xmppNet
.
registerService
(
entity
);
},
(
bindError
)
=>
{
console
.
log
(
'
client: discoPubsubService: unknown error:
'
+
bindError
.
error
);
...
...
src/xmpp/discover/entity.js
View file @
db10fe49
...
...
@@ -15,13 +15,20 @@ class Entity {
// value: identity name
this
.
identities
=
new
Map
();
// Features and protocols supported by the entity
this
.
features
=
[]
;
this
.
features
=
new
Set
()
;
this
.
protocols
=
new
Map
();
}
get
identityMap
()
{
return
this
.
identities
;
}
get
featureSet
()
{
return
this
.
features
;
}
/*
* _identity is a <identity> XML Node
* _xmllang is the client preerend language
*/
addIdentity
(
_identity
)
{
let
type
=
_identity
.
getAttribute
(
'
type
'
);
...
...
@@ -48,6 +55,6 @@ class Entity {
* _feature is a <feature> XML Node
*/
addFeature
(
_feature
)
{
this
.
features
.
push
(
_feature
.
getAttribute
(
'
var
'
));
this
.
features
.
add
(
_feature
.
getAttribute
(
'
var
'
));
}
}
src/xmpp/network.js
View file @
db10fe49
...
...
@@ -17,6 +17,7 @@ class Network {
// key: serviceid (jid?)
// object: array(metaData, nodeMap, collectionMap, leafMap)
// metaData: name (string), features (set)
this
.
pubsub
=
new
Map
();
// key: serviceid
...
...
@@ -28,18 +29,19 @@ class Network {
switch
(
typeof
(
_netElement
))
{
case
'
Entity
'
:
for
(
let
[
idKey
,
idValue
]
of
_netElement
.
identit
ies
)
{
for
(
let
[
idKey
,
idValue
]
of
_netElement
.
identit
yMap
)
{
if
(
idKey
.
xmllang
==
'
en
'
||
idKey
.
xmllang
==
this
.
xmllang
)
{
// If pubsub service is discoverd save it on the pubsub/services path
if
(
idKey
.
type
==
"
pubsub
"
&&
idKey
.
category
==
"
service
"
)
{
let
service
=
[];
service
[
"
metaData
"
]
=
[];
service
[
"
metaData
"
][
"
name
"
]
=
idValue
;
service
[
"
collections
"
]
=
new
Map
();
service
[
"
leaves
"
]
=
new
Map
();
let
service
=
new
Map
();
service
.
set
(
"
metaData
"
,
new
Map
());
service
.
get
(
"
metaData
"
).
set
(
"
name
"
,
idValue
);
service
.
get
(
"
metaData
"
).
set
(
"
features
"
,
new
Set
());
service
.
set
(
"
collections
"
,
new
Map
());
service
.
set
(
"
leaves
"
,
new
Map
());
this
.
pubsub
.
set
(
_netElement
.
jid
,
service
);
}
}
...
...
@@ -50,26 +52,26 @@ class Network {
for
(
let
[
idKey
,
idValue
]
of
_netElement
.
identities
)
{
if
(
idKey
.
type
==
"
pubsub
"
&&
idKey
.
category
==
"
collection
"
)
{
service
[
"
collections
"
].
set
(
idKey
.
node
,
[]
);
service
.
get
(
"
collections
"
).
set
(
idKey
.
node
,
new
Map
()
);
}
if
(
idKey
.
type
==
"
pubsub
"
&&
idKey
.
category
==
"
leaf
"
)
{
service
[
"
leaves
"
].
set
(
idKey
.
node
,
[]
);
service
.
get
(
"
leaves
"
).
set
(
idKey
.
node
,
new
Map
()
);
}
}
}
for
(
let
feature
of
_netElement
.
features
)
{
let
featureNode
=
entityNode
.
createElement
(
"
feature
"
);
featureNode
.
addAttribute
(
"
type
"
,
feature
)
for
(
let
feature
of
_netElement
.
featureSet
)
{
// TODO: decide which features to track and how to use them
service
.
get
(
"
metaData
"
).
get
(
"
features
"
).
add
(
feature
);
}
break
;
}
browser
.
runtime
.
sendMessage
({
'
subject
'
:
'
refreshNetwork
'
});
browser
.
runtime
.
sendMessage
({
'
subject
'
:
'
refreshNetwork
'
});
}
/*
...
...
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