Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: c75e23cf3e95897e3271ba91b96756603e9ec15f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package org.eclipse.net4j.buddies.internal.server.protocol;

import org.eclipse.net4j.buddies.internal.protocol.BuddyStateIndication;
import org.eclipse.net4j.buddies.internal.server.ServerBuddy;
import org.eclipse.net4j.buddies.protocol.ISession;
import org.eclipse.net4j.buddies.protocol.IBuddy.State;
import org.eclipse.net4j.buddies.server.IBuddyAdmin;

import java.util.Map;

/**
 * @author Eike Stepper
 */
public class ServerBuddyStateIndication extends BuddyStateIndication
{
  public ServerBuddyStateIndication()
  {
  }

  @Override
  protected void stateChanged(String userID, State state)
  {
    synchronized (IBuddyAdmin.INSTANCE)
    {
      Map<String, ISession> sessions = IBuddyAdmin.INSTANCE.getSessions();
      ISession session = sessions.get(userID);
      if (session != null)
      {
        ServerBuddy buddy = (ServerBuddy)session.getSelf();
        buddy.setState(state);
      }
    }
  }
}

Back to the top