-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from stzups/feature/data-persistence
v0.2.6 Design
- Loading branch information
Showing
28 changed files
with
302 additions
and
242 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
##v0.1 | ||
Add real time drawing | ||
|
||
- Change file structure and how files are served | ||
- Fix custom invite URL | ||
- Automatic connection | ||
|
||
##v0.2 | ||
Basic functionality to allow for more features to be added | ||
|
||
###v0.2.1 | ||
Room to document based model | ||
|
||
- Add sidebar | ||
- Change offset points to absolute points in draw | ||
- Refactor packets | ||
- Refactor js | ||
- Event based WebSocketHandler | ||
- Change how URLs work | ||
|
||
###v0.2.2 | ||
Add document opening/closing | ||
|
||
- Change how queued packets work | ||
- Documents are saved before closed | ||
- Change protocol again | ||
|
||
###v0.2.3 | ||
Flat file data persistence | ||
|
||
- Remove ConsoleManager | ||
- Add shutdown hooks for saving | ||
- Change handshake | ||
- Functioning Java serialization | ||
- Complete rework of config system | ||
- SSL support | ||
|
||
###v0.2.4 | ||
User identity | ||
|
||
- Change URL parsing | ||
- Add HTTP cache as a config option | ||
- Session management | ||
- Sessions are linked to documents | ||
- Improve toString debug | ||
|
||
###v0.2.5 | ||
Multiple clients per user | ||
|
||
- Change how sessions are handled | ||
- Clean up script loading | ||
- Fix hashcode issues | ||
|
||
###v0.2.6 | ||
Design | ||
- Clean up CSS | ||
- Add changelog | ||
- Add invite/connected users toolbar | ||
- "Fix" canvas resize | ||
- Change/clean up config system | ||
- Improve client debug | ||
- Better local user with different handshake |
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
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
68 changes: 66 additions & 2 deletions
68
board-server/src/main/java/net/stzups/board/config/Config.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 |
---|---|---|
@@ -1,5 +1,69 @@ | ||
package net.stzups.board.config; | ||
|
||
public interface Config<T> { | ||
T get(String key); | ||
import java.nio.ByteBuffer; | ||
import java.util.List; | ||
|
||
/** | ||
* Used to store and retrieve key-value pairs by finding the first result from many different strategies. | ||
*/ | ||
public class Config {//todo probably needs a better name | ||
private List<ConfigProvider> configProviders; | ||
|
||
/** | ||
* Constructs a new ConfigProvider from its builder | ||
*/ | ||
Config(List<ConfigProvider> configProviders) { | ||
this.configProviders = configProviders; | ||
} | ||
|
||
/** | ||
* Gets a String value for a String key from any config provider | ||
*/ | ||
public String get(String key) { | ||
for (ConfigProvider configProvider : configProviders) { | ||
String value = configProvider.get(key); | ||
if (value != null) { | ||
return value; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public int getInt(String key) { | ||
try { | ||
return Integer.parseInt(get(key)); | ||
} catch (NumberFormatException e) { | ||
return 0; | ||
} | ||
} | ||
|
||
public int getInt(String key, int defaultValue) { | ||
try { | ||
return Integer.parseInt(get(key)); | ||
} catch (NumberFormatException e) { | ||
return defaultValue; | ||
} | ||
} | ||
|
||
public boolean getBoolean(String key) { | ||
return Boolean.parseBoolean(get(key)); | ||
} | ||
|
||
public boolean getBoolean(String key, boolean defaultValue) { | ||
String value = get(key); | ||
if (value == null) { | ||
return defaultValue; | ||
} else { | ||
return Boolean.parseBoolean(key); | ||
} | ||
} | ||
|
||
public String get(String key, String defaultValue) { | ||
String value = get(key); | ||
if (value == null) { | ||
return defaultValue; | ||
} | ||
return value; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
board-server/src/main/java/net/stzups/board/config/ConfigBuilder.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,22 @@ | ||
package net.stzups.board.config; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* Builds a {@link Config} with several different configs. | ||
*/ | ||
public class ConfigBuilder { | ||
private List<ConfigProvider> configProviders = new ArrayList<>(); | ||
|
||
public ConfigBuilder() {} | ||
|
||
public ConfigBuilder addConfig(ConfigProvider configProvider) { | ||
configProviders.add(configProvider); | ||
return this; | ||
} | ||
|
||
public Config build() { | ||
return new Config(configProviders); | ||
} | ||
} |
47 changes: 2 additions & 45 deletions
47
board-server/src/main/java/net/stzups/board/config/ConfigProvider.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 |
---|---|---|
@@ -1,48 +1,5 @@ | ||
package net.stzups.board.config; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Used to store and retrieve key-value pairs by finding the first result from many different strategies. | ||
*/ | ||
public class ConfigProvider {//todo probably needs a better name | ||
private List<StringConfig> stringConfigs; | ||
|
||
/** | ||
* Constructs a new ConfigProvider from its builder | ||
* @param stringConfigs configs for String | ||
*/ | ||
ConfigProvider(List<StringConfig> stringConfigs) { | ||
this.stringConfigs = stringConfigs; | ||
} | ||
|
||
/** | ||
* Searches all StringConfigs for a key and gets | ||
* @param key the key to match | ||
* @return the matching string, or null if none of the string configs have the key | ||
*/ | ||
public String get(String key) { | ||
for (Config<String> config : stringConfigs) { | ||
String value = config.get(key); | ||
if (value != null) { | ||
return value; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
/** | ||
* Searches all configs that provide a String value for a key, which if not found will instead return the defaultValue | ||
* @param key the key to match | ||
* @param defaultValue the value to return if a value for the key is not found | ||
* @return the value for the key, or the defaultValue | ||
*/ | ||
public String get(String key, String defaultValue) { | ||
String value = get(key); | ||
if (value == null) { | ||
return defaultValue; | ||
} | ||
return value; | ||
} | ||
public interface ConfigProvider { | ||
String get(String key); | ||
} |
22 changes: 0 additions & 22 deletions
22
board-server/src/main/java/net/stzups/board/config/ConfigProviderBuilder.java
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
board-server/src/main/java/net/stzups/board/config/StringConfig.java
This file was deleted.
Oops, something went wrong.
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
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
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
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
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
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
Oops, something went wrong.