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
8d8edf8a
Commit
8d8edf8a
authored
Mar 31, 2018
by
Adrien Dorsaz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip: adding network scheme (not finished, only the main idea)
parent
7ddfb31d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
115 additions
and
11 deletions
+115
-11
manifest.json
manifest.json
+1
-0
src/xmpp/client.js
src/xmpp/client.js
+18
-10
src/xmpp/constants.js
src/xmpp/constants.js
+3
-0
src/xmpp/discover/entity.js
src/xmpp/discover/entity.js
+2
-1
src/xmpp/network.js
src/xmpp/network.js
+91
-0
No files found.
manifest.json
View file @
8d8edf8a
...
...
@@ -29,6 +29,7 @@
"src/xmpp/core/iq.js"
,
"src/xmpp/discover/entity.js"
,
"src/xmpp/server.js"
,
"src/xmpp/network.js"
,
"src/xmpp/client.js"
,
"src/xmpp-pane-main.js"
]
...
...
src/xmpp/client.js
View file @
8d8edf8a
...
...
@@ -40,6 +40,9 @@ class Client {
this
.
bindError
=
null
;
this
.
tls
=
false
;
// XMPP Network discovered
this
.
xmppNet
=
new
Network
(
this
.
config
.
xmllang
);
// Contracts
this
.
contracts
=
{};
this
.
lastContractId
=
0
;
...
...
@@ -395,11 +398,16 @@ class Client {
* Discover an Entity
*
* Node attribute is optional
* This is WIP and will be replaced by "discoverPubSubService"
* the idea will be to:
* * disco#info on service name
* * disco#items on first level of service
* * disco#info on each of discovered node of first level service
*/
disco
ver
(
_entity
,
_node
=
null
)
{
console
.
log
(
'
client: disco
ver
: starting
'
);
disco
PubsubService
(
_entity
,
_node
=
null
)
{
console
.
log
(
'
client: disco
PubsubService
: starting
'
);
let
iq
=
new
IQ
({
let
iq
info
=
new
IQ
({
from
:
this
.
config
.
jid
,
to
:
_entity
,
id
:
this
.
lastContractId
++
,
...
...
@@ -407,18 +415,18 @@ class Client {
});
if
(
_node
)
{
iq
.
addExtendedAttribute
(
'
node
'
,
_node
);
iq
Info
.
addExtendedAttribute
(
'
node
'
,
_node
);
}
let
query
=
this
.
dom
.
createElementNS
(
Constants
.
NS_DISCO_INFO
,
'
query
'
);
iq
.
build
(
query
)
.
then
((
iq
Element
)
=>
{
iq
Info
.
build
(
query
)
.
then
((
iq
InfoService
)
=>
{
// TODO: Add expected namespace as Constants.NS_DISCO_INFO
this
.
promise
(
iq
Element
,
'
iq
'
)
this
.
promise
(
iq
InfoService
,
'
iq
'
)
.
then
(
(
iqResponse
)
=>
{
let
entity
=
new
Entity
();
let
entity
=
new
Entity
(
iqResponse
.
getElementsByTagName
(
'
iq
'
)[
0
].
getAttribute
(
'
from
'
)
);
let
identities
=
iqResponse
.
getElementsByTagName
(
'
identity
'
);
let
features
=
iqResponse
.
getElementsByTagName
(
'
feature
'
);
...
...
@@ -430,10 +438,10 @@ class Client {
entity
.
addFeature
(
features
[
i
]);
}
console
.
log
(
'
client: disco
ver
: succeed:
'
+
entity
);
console
.
log
(
'
client: disco
PubsubService
: succeed:
'
+
entity
);
},
(
bindError
)
=>
{
console
.
log
(
'
client: disco
ver
: unknown error:
'
+
bindError
.
error
);
console
.
log
(
'
client: disco
PubsubService
: unknown error:
'
+
bindError
.
error
);
});
});
}
...
...
src/xmpp/constants.js
View file @
8d8edf8a
...
...
@@ -46,4 +46,7 @@ class Constants {
static
get
NS_DISCO_INFO
()
{
return
"
http://jabber.org/protocol/disco#info
"
;
}
static
get
NS_DISCO_ITEMS
()
{
return
"
http://jabber.org/protocol/disco#items
"
;
}
}
src/xmpp/discover/entity.js
View file @
8d8edf8a
...
...
@@ -27,8 +27,9 @@ class Entity {
let
type
=
_identity
.
getAttribute
(
'
type
'
);
let
category
=
_identity
.
getAttribute
(
'
category
'
);
let
name
=
_identity
.
getAttribute
(
'
name
'
);
let
node
=
_identity
.
getAttribute
(
'
node
'
);
let
idKey
=
[
'
type
'
:
type
,
'
category
'
:
category
];
let
idKey
=
[
'
type
'
:
type
,
'
category
'
:
category
,
'
node
'
:
node
];
let
identity
=
this
.
identities
.
get
(
idKey
)
if
(
identity
)
{
...
...
src/xmpp/network.js
0 → 100644
View file @
8d8edf8a
/*
* Network is a representation of the discovered XMPP network
*
* It receives result from discovery and return adapted HTML code
* to visualize the network.
*/
class
Network
{
constructor
(
_xmllang
)
{
// Prefered language to use if possible
this
.
xmllang
=
_xmllang
;
// Map model
this
.
discover
=
new
Map
();
// key: jid
this
.
entities
=
new
Map
();
// key: serviceid (jid?)
// object: array(metaData, nodeMap, collectionMap, leafMap)
this
.
pubsub
=
new
Map
();
// key: serviceid
// object: nodeid
this
.
pubsubSubscriptions
=
new
Map
();
}
registerService
(
_netElement
)
{
switch
(
typeof
(
_netElement
))
{
case
'
Entity
'
:
for
(
let
[
idKey
,
idValue
]
of
_netElement
.
identities
)
{
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
();
this
.
pubsub
.
set
(
_netElement
.
jid
,
service
);
}
}
if
(
this
.
pubsub
.
has
(
_netElement
.
jid
)){
let
service
=
this
.
pubsub
.
get
(
_netElement
.
jid
);
for
(
let
[
idKey
,
idValue
]
of
_netElement
.
identities
)
{
if
(
idKey
.
type
==
"
pubsub
"
&&
idKey
.
category
==
"
collection
"
)
{
service
[
"
collections
"
].
set
(
idKey
.
node
,
[]);
}
if
(
idKey
.
type
==
"
pubsub
"
&&
idKey
.
category
==
"
leaf
"
)
{
service
[
"
leaves
"
].
set
(
idKey
.
node
,
[]);
}
}
}
for
(
let
feature
of
_netElement
.
features
)
{
let
featureNode
=
entityNode
.
createElement
(
"
feature
"
);
featureNode
.
addAttribute
(
"
type
"
,
feature
)
// TODO: decide which features to track and how to use them
}
break
;
}
chrome
.
runtime
.
sendMessage
(
"
refreshNetwork
"
);
}
/*
* Create a JSON representation of the network
* This representation is only used to save the network to local storage
*/
stringify
()
{
let
jsonNet
;
return
jsonNet
;
}
/*
* Read the network from a JSON object
* This will be used to restore network from local storage
*/
parse
(
_jsonNet
)
{
return
;
}
}
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