I have the following Comet server:
object UserServer extends LiftActor with ListenerManager {
private var users: List[UserItem] = Nil
def createUpdate = users
override def lowPriority = {
case UserItem(user, room, active, stamp) => {
users :+= UserItem(user, room, active, stamp);
updateListeners()
}
}
}
Currently each time the form is submitted a new UserItem is added to the users list. What I'm trying to do is each time the server receives a new user, instead of concatenating to the list it should overwrite an existing item with the same user and room handle.
So if the list contains the following:
UserItem("jam_2323", "demo-room", "James", "1320073365")
UserItem("jim_4533", "demo-room", "Jim", "1320073365")
The next time these users submit the form the above two items in the list will be replaced with the new stamp value:
UserItem("jam_2323", "demo-room", "James", "1320073435")
UserItem("jim_4533", "demo-room", "Jim", "1320073435")
Thanks in advance for any help, much appreciated :)
UserItem, you can simply match on it as an object. You should also either prepend to theList, or use aVector; appending to a List performs very poorly.case u: UserItem => users ::= u.