예제 #1
0
파일: list.go 프로젝트: rosatolen/coyim
// PeerBecameUnavailable marks the peer as unavailable if they exist
// Returns true if they existed, otherwise false
func (l *List) PeerBecameUnavailable(jid string) bool {
	if p, exist := l.Get(jid); exist {
		resource := utils.ResourceFromJid(jid)
		if resource != "" {
			p.RemoveResource(resource)
			p.Online = p.HasResources()
		} else {
			p.ClearResources()
			p.Online = false
		}

		return true
	}

	return false
}
예제 #2
0
파일: list.go 프로젝트: twstrike/coyim
// PeerPresenceUpdate updates the status for the peer
// It returns true if it actually updated the status of the user
func (l *List) PeerPresenceUpdate(jid, status, statusMsg, belongsTo string) bool {
	resource := utils.ResourceFromJid(jid)

	if p, ok := l.Get(jid); ok {
		oldOnline := p.Online
		p.Online = true
		p.AddResource(resource)
		if p.Status != status || p.StatusMsg != statusMsg {
			p.Status = status
			p.StatusMsg = statusMsg
			return true
		}
		return !oldOnline
	}

	l.AddOrMerge(PeerWithState(jid, status, statusMsg, belongsTo, resource))
	return true
}