X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;ds=sidebyside;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Flibrary%2FRemoteLibraryServer.java;h=221fbdfc05b21153f0c6a33ee012657f0b19cd95;hb=e604986c4208da0091d26bc0e1c4feb4ff3c588f;hp=566c70fa69a572043ea6749ae5361b05b6ac4b73;hpb=e42573a004fac26378c693ce9ef0d6319713c682;p=fanfix.git
diff --git a/src/be/nikiroo/fanfix/library/RemoteLibraryServer.java b/src/be/nikiroo/fanfix/library/RemoteLibraryServer.java
index 566c70f..221fbdf 100644
--- a/src/be/nikiroo/fanfix/library/RemoteLibraryServer.java
+++ b/src/be/nikiroo/fanfix/library/RemoteLibraryServer.java
@@ -9,10 +9,32 @@ import be.nikiroo.utils.Version;
import be.nikiroo.utils.serial.ConnectActionServer;
import be.nikiroo.utils.serial.Server;
+/**
+ * Create a new remote server that will listen for order on the given port.
+ *
+ * The available commands are:
+ *
+ * - GET_METADATA *: will get the metadata of all the stories in the library
+ * - GET_STORY [luid]: will return the given story if it exists (or NULL if
+ * not)
+ *
+ *
+ * @author niki
+ */
public class RemoteLibraryServer extends Server {
+ /**
+ * Create a new remote server (will not be active until
+ * {@link RemoteLibraryServer#start()} is called).
+ *
+ * @param port
+ * the port to listen on
+ *
+ * @throws IOException
+ * in case of I/O error
+ */
public RemoteLibraryServer(int port) throws IOException {
- super(Version.getCurrentVersion(), port, true);
+ super(port, true);
}
@Override
@@ -32,16 +54,20 @@ public class RemoteLibraryServer extends Server {
System.out.println(String.format("COMMAND: [%s], ARGS: [%s]", command,
args));
- if (command != null) {
- if (command.equals("GET_METADATA")) {
- if (args != null && args.equals("*")) {
- List metas = Instance.getLibrary().getMetas(null);
- return metas.toArray(new MetaData[] {});
- }
- } else if (command.equals("GET_STORY")) {
- if (args != null) {
- return Instance.getLibrary().getStory(args, null);
- }
+ // TODO: progress (+send name + %age info back to client)
+
+ if ("GET_METADATA".equals(command)) {
+ if (args != null && args.equals("*")) {
+ List metas = Instance.getLibrary().getMetas(null);
+ return metas.toArray(new MetaData[] {});
+ }
+ } else if ("GET_STORY".equals(command)) {
+ if (args != null) {
+ return Instance.getLibrary().getStory(args, null);
+ }
+ } else if ("GET_COVER".equals(command)) {
+ if (args != null) {
+ return Instance.getLibrary().getCover(args);
}
}