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
ef51d5f2
Commit
ef51d5f2
authored
5 years ago
by
Tiger Wang
Committed by
Tiger Wang
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add identifier to all chatroom messages so we can ignore ourselves
parent
070a9b1d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/connection/XMPP.js
+10
-1
10 additions, 1 deletion
src/connection/XMPP.js
with
10 additions
and
1 deletion
src/connection/XMPP.js
+
10
−
1
View file @
ef51d5f2
import
{
client
,
xml
}
from
"
@xmpp/client
"
import
uuid
from
"
uuid
"
const
GROUP_MESSAGE_ID
=
"
I smell JOJO!
"
// Ur. Ugly.
const
XMPP_STATUS_ROOM_CREATED
=
"
201
"
// 201 Created
export
default
class
XMPPConnection
extends
EventTarget
{
...
...
@@ -29,6 +30,7 @@ export default class XMPPConnection extends EventTarget {
{
type
:
"
groupchat
"
,
to
:
channelIdent
,
id
:
GROUP_MESSAGE_ID
,
},
xml
(
"
body
"
,
{},
message
),
)
...
...
@@ -40,7 +42,7 @@ export default class XMPPConnection extends EventTarget {
const
channelIdent
=
`
${
this
.
channel
}
@conference.xmpp.lets-draw.live`
const
presence
=
xml
(
"
iq
"
,
{
id
:
"
create1
"
,
to
:
channelIdent
,
type
:
"
set
"
},
{
id
:
GROUP_MESSAGE_ID
,
to
:
channelIdent
,
type
:
"
set
"
},
xml
(
"
query
"
,
{
xmlns
:
"
http://jabber.org/protocol/muc#owner
"
},
...
...
@@ -72,6 +74,13 @@ export default class XMPPConnection extends EventTarget {
})
xmpp
.
on
(
"
stanza
"
,
(
stanza
)
=>
{
const
stanzaId
=
stanza
.
getAttr
(
"
id
"
)
if
(
stanzaId
&&
stanzaId
===
GROUP_MESSAGE_ID
)
{
// Messages sent to the room as echoed back
// Ignore our own messages to prevent loops
return
}
if
(
stanza
.
is
(
"
message
"
))
{
this
.
dispatchEvent
(
new
CustomEvent
(
"
stanza
"
,
{
...
...
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