-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathLogoutHandler.java
31 lines (27 loc) · 1010 Bytes
/
LogoutHandler.java
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
package com.doing.more.java.example.handlers;
import com.doing.more.java.example.StoreModel;
import com.doing.more.java.example.User;
import com.doing.more.java.example.appcontrol.Handler;
import json.JSONOutputStream;
import java.util.HashMap;
public class LogoutHandler implements Handler {
@Override
public void handleIt(HashMap<String, Object> dataMap) {
String sessionID = (String)dataMap.get("id");
StoreModel theModel = (StoreModel)dataMap.get("model");
User foundUser = theModel.getUserBySessionID(sessionID);
if(foundUser != null){
foundUser.setSession("");
theModel.updateUser(foundUser);
}
HashMap<String,Object> responseMap = new HashMap<>();
responseMap.put("id","");
JSONOutputStream outToClient = (JSONOutputStream)dataMap.get("toClient");
try {
outToClient.writeObject(responseMap);
}
catch (Exception e) {
e.printStackTrace();
}
}
}