1 package org.argosfields.action.server;
2
3 import org.argosfields.ArgosFields;
4 import org.argosfields.action.BaseAction;
5 import org.argosfields.multi.GameClientAdapter;
6 import org.argosfields.multi.client.GameClient;
7 import org.argosfields.multi.client.IGameClient;
8 import org.argosfields.multi.server.ServerInfo;
9 import org.argosfields.service.ILoginManager;
10 import org.argosfields.spring.ClientContextHelper;
11 import org.eclipse.swt.widgets.Event;
12
13 /***
14 * DisconnectAction.java
15 * @author Xavier Cho
16 * @version $Revision: 1.5 $ $Date: 2004/04/17 18:21:02 $
17 */
18 public class DisconnectAction extends BaseAction {
19
20 public DisconnectAction(final ArgosFields application) {
21 super(application);
22
23 IGameClient client = GameClient.getInstance();
24 client.addGameClientListener(new GameClientAdapter() {
25
26 public void sessionStarted(final ServerInfo info) {
27 setEnabled(true);
28 }
29
30 public void sessionEnded() {
31 setEnabled(false);
32 }
33 });
34
35 setEnabled(client.isSessionStarted());
36 }
37
38 /***
39 * @see org.eclipse.jface.action.IAction#runWithEvent(org.eclipse.swt.widgets.Event)
40 */
41 public void runWithEvent(final Event event) {
42 IGameClient client = GameClient.getInstance();
43 String sessionId = client.getSessionId();
44
45 client.endSession();
46
47 ClientContextHelper helper = ClientContextHelper.getInstance();
48 ILoginManager manager = helper.getLoginManager();
49 manager.logout(sessionId);
50 }
51 }
This page was automatically generated by Maven