1 package be
.nikiroo
.fanfix
;
4 import java
.io
.IOException
;
8 import be
.nikiroo
.fanfix
.data
.MetaData
;
9 import be
.nikiroo
.utils
.Version
;
10 import be
.nikiroo
.utils
.serial
.ConnectActionServer
;
11 import be
.nikiroo
.utils
.serial
.Server
;
13 public class RemoteLibraryServer
extends Server
{
15 public RemoteLibraryServer(int port
) throws IOException
{
16 super(Version
.getCurrentVersion(), port
, true);
20 protected Object
onRequest(ConnectActionServer action
,
21 Version clientVersion
, Object data
) throws Exception
{
22 String command
= null;
24 if (data
instanceof String
) {
25 command
= (String
) data
;
26 int pos
= command
.indexOf(" ");
28 args
= command
.substring(pos
+ 1);
29 command
= command
.substring(0, pos
);
33 System
.out
.println(String
.format("COMMAND: [%s], ARGS: [%s]", command
,
36 if (command
!= null) {
37 if (command
.equals("GET_METADATA")) {
38 if (args
!= null && args
.equals("*")) {
39 List
<MetaData
> metas
= Instance
.getLibrary().getMetas(null);
40 return metas
.toArray(new MetaData
[] {});
42 } else if (command
.equals("GET_STORY")) {
44 return Instance
.getLibrary().getStory(args
, null);