Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,4 @@ module.exports = class MucHandler
delete @rooms[roomId]
room

# vim: tabstop=4:softtabstop=4:shiftwidth=4:noexpandtab
1 change: 1 addition & 0 deletions message.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ module.exports = class Message
for key, value of object
this[key] = value

# vim: tabstop=4:softtabstop=4:shiftwidth=4:noexpandtab
25 changes: 24 additions & 1 deletion room.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ module.exports = class Room extends events.EventEmitter
constructor: (@roomId) ->
events.EventEmitter.call(this)
@roster = {}
@jids = {}

updateJids: () ->
temp = {}
for nick, user of @roster
if user.jid
jid = user.jid.split("/",1)[0]
if jid not of temp
temp[jid] = user
@jids = temp

sendGroup: (message) ->
return if not @connection
Expand Down Expand Up @@ -75,10 +85,12 @@ module.exports = class Room extends events.EventEmitter
return

@emit 'groupMessage',
id: stanza.attrs.id
to: stanza.attrs.to
nick: nick
text: bodyElement.getText()
delay: stanza.getChild('delay')?.attrs.stamp
stanza: stanza

availableHandler: (stanza) ->
nick = stanza.from.split("/")[1]
Expand All @@ -88,7 +100,13 @@ module.exports = class Room extends events.EventEmitter

# if nick isn't already on the roster, add it and announce the arrival
if nick not of @roster
@roster[nick] = new User(stanza)
user = new User(stanza)
user.nick = nick
@roster[nick] = user
if user.jid
jid = user.jid.split("/",1)[0]
if jid not of @jids
@jids[jid] = user
if not selfPresence and @connection
this.emit 'joined', @roster[nick]
else
Expand Down Expand Up @@ -139,9 +157,14 @@ module.exports = class Room extends events.EventEmitter
return

status = statusElems[0].getText() if statusElems.length > 0
jid = @roster[nick].jid
delete @roster[nick]
if jid
@updateJids()
this.emit 'parted',
nick: nick
jid: jid
status: status or ""
self: selfPresence

# vim: tabstop=4:softtabstop=4:shiftwidth=4:noexpandtab
1 change: 1 addition & 0 deletions user.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ module.exports = class User

this

# vim: tabstop=4:softtabstop=4:shiftwidth=4:noexpandtab