-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- added Logger #16 - back to the old style session storing. Storing data to environmental variables
- Loading branch information
Damian Staszewski
committed
Oct 22, 2017
1 parent
57fb02b
commit dc70a57
Showing
2 changed files
with
40 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/main/java/com/github/stachu540/hirezapi/api/HiRezSession.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.github.stachu540.hirezapi.api; | ||
|
||
import com.github.stachu540.hirezapi.enums.url.BasePlatform; | ||
import com.github.stachu540.hirezapi.enums.url.EPaladins; | ||
import com.github.stachu540.hirezapi.enums.url.ESmite; | ||
|
||
import java.util.*; | ||
|
||
public class HiRezSession extends HashMap<BasePlatform, String> { | ||
HiRezSession() { | ||
super(); | ||
Map<String, String> envs = System.getenv(); | ||
List<BasePlatform> platforms = new ArrayList<>(); | ||
platforms.addAll(Arrays.asList(ESmite.values())); | ||
platforms.addAll(Arrays.asList(EPaladins.values())); | ||
platforms.forEach(platform -> { | ||
if (envs.containsKey(platform.getName())) | ||
put(platform, envs.get(platform.getName())); | ||
}); | ||
} | ||
|
||
@Override | ||
public String put(BasePlatform platform, String sessionId) { | ||
if (!System.getenv().containsKey(platform.getName()) || !System.getenv().get(platform.getName()).equals(sessionId)) | ||
System.getenv().put(platform.getName(), sessionId); | ||
|
||
remove(platform); | ||
return super.put(platform, sessionId); | ||
} | ||
} |