Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drawing-app
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hlgr
drawing-app
Commits
55c24eeb
Commit
55c24eeb
authored
5 years ago
by
Tiger Wang
Committed by
Tiger Wang
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
No longer send room presence with every message
parent
b0425cd6
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/connection/XMPP.js
+27
-12
27 additions, 12 deletions
src/connection/XMPP.js
with
27 additions
and
12 deletions
src/connection/XMPP.js
+
27
−
12
View file @
55c24eeb
import
{
client
,
xml
}
from
"
@xmpp/client
"
import
uuid
from
"
uuid
"
import
debug
from
"
@xmpp/debug
"
export
default
class
XMPPConnection
extends
EventTarget
{
async
joinChannel
(
channel
)
{
joinChannel
(
channel
)
{
const
channelIdent
=
`
${
channel
}
@conference.xmpp.lets-draw.live/
${
this
.
username
}
`
const
presence
=
xml
(
"
presence
"
,
{
to
:
channelIdent
},
xml
(
"
x
"
,
{
xmlns
:
"
http://jabber.org/protocol/muc
"
}),
)
this
.
sendOrQueue
(
presence
)
}
sendOrQueue
(
message
)
{
if
(
this
.
online
)
{
await
this
.
xmpp
.
send
(
presenc
e
)
this
.
xmpp
.
send
(
messag
e
)
}
else
{
this
.
queue
.
push
(
presenc
e
)
this
.
queue
.
push
(
messag
e
)
}
}
}
async
sendChannelMessage
(
channel
,
message
)
{
sendChannelMessage
(
channel
,
message
)
{
const
channelIdent
=
`
${
channel
}
@conference.xmpp.lets-draw.live`
const
sentm
essage
=
xml
(
const
wrappedM
essage
=
xml
(
"
message
"
,
{
type
:
"
groupchat
"
,
...
...
@@ -28,7 +32,7 @@ export default class XMPPConnection extends EventTarget {
xml
(
"
body
"
,
{},
message
),
)
await
this
.
xmpp
.
send
(
sentm
essage
)
this
.
sendOrQueue
(
wrappedM
essage
)
}
constructor
()
{
...
...
@@ -45,6 +49,19 @@ export default class XMPPConnection extends EventTarget {
password
:
"
beartest
"
,
})
this
.
xmpp
=
xmpp
debug
(
xmpp
,
true
)
xmpp
.
on
(
'
status
'
,
status
=>
{
console
.
debug
(
'
🛈
'
,
'
status
'
,
status
)
})
xmpp
.
on
(
'
input
'
,
input
=>
{
console
.
debug
(
'
⮈
'
,
input
)
})
xmpp
.
on
(
'
output
'
,
output
=>
{
console
.
debug
(
'
⮊
'
,
output
)
})
xmpp
.
on
(
"
error
"
,
(
err
)
=>
{
console
.
error
(
"
❌
"
,
err
.
toString
())
})
...
...
@@ -53,7 +70,7 @@ export default class XMPPConnection extends EventTarget {
this
.
online
=
false
})
xmpp
.
on
(
"
stanza
"
,
async
(
stanza
)
=>
{
xmpp
.
on
(
"
stanza
"
,
(
stanza
)
=>
{
if
(
stanza
.
is
(
"
message
"
))
{
this
.
dispatchEvent
(
new
CustomEvent
(
"
stanza
"
,
{
...
...
@@ -77,13 +94,11 @@ export default class XMPPConnection extends EventTarget {
})
xmpp
.
start
().
catch
(
console
.
error
)
this
.
joinChannel
(
"
imperial
"
)
this
.
xmpp
=
xmpp
}
sneakilySendTheOtherTeamOur
(
secrets
)
{
this
.
joinChannel
(
"
imperial
"
).
then
(
this
.
sendChannelMessage
(
"
imperial
"
,
secrets
),
)
this
.
sendChannelMessage
(
"
imperial
"
,
secrets
)
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment