1 package be
.nikiroo
.fanfix
.library
;
3 import java
.io
.IOException
;
6 import be
.nikiroo
.fanfix
.Instance
;
7 import be
.nikiroo
.fanfix
.data
.MetaData
;
8 import be
.nikiroo
.utils
.Version
;
9 import be
.nikiroo
.utils
.serial
.ConnectActionServer
;
10 import be
.nikiroo
.utils
.serial
.Server
;
12 public class RemoteLibraryServer
extends Server
{
14 public RemoteLibraryServer(int port
) throws IOException
{
15 super(Version
.getCurrentVersion(), port
, true);
19 protected Object
onRequest(ConnectActionServer action
,
20 Version clientVersion
, Object data
) throws Exception
{
21 String command
= null;
23 if (data
instanceof String
) {
24 command
= (String
) data
;
25 int pos
= command
.indexOf(" ");
27 args
= command
.substring(pos
+ 1);
28 command
= command
.substring(0, pos
);
32 System
.out
.println(String
.format("COMMAND: [%s], ARGS: [%s]", command
,
35 if (command
!= null) {
36 if (command
.equals("GET_METADATA")) {
37 if (args
!= null && args
.equals("*")) {
38 List
<MetaData
> metas
= Instance
.getLibrary().getMetas(null);
39 return metas
.toArray(new MetaData
[] {});
41 } else if (command
.equals("GET_STORY")) {
43 return Instance
.getLibrary().getStory(args
, null);