Utilizing Clientcontroller for Commandfusion (1 Viewer)

KeKs0r

Portal Member
October 27, 2008
41
0
Home Country
Germany Germany
Hi,

this question is not directly connected to ipimp, but i would need some expertise on the topic :)

I am wondering, whether it is possible to use Clientcontroller plugin to handle http requests from another source than the ipimp webinterface. I am interested in an all in one remote and i wanted to try it with commandfusion. It is a flexible app for the iphone where you can define and customize remote layouts and configure http requests. I have another hardware component which converts some tcp messages to IR messages in order to control my Tv or receiver. It would be great to control all these things including my htpc with mediaportal with the same app. THerefore i would like to know if it is possible to use the clientcontroller to receive the htpc messages and then trigger some actions or key inputs in mp.

Thanks
Marc
 

cheezey

Community Plugin Dev
August 26, 2004
1,560
312
55
West Yorks, UK
Home Country
United Kingdom United Kingdom
Yes it is possible, and the MPCC plugin was written to provide a generic interface, Yatse also uses this plugin.

Communication with the MPCC uses Json, you construct a Json request, send it via a tcp channel or http post and receive a Json response. If you set your log level to debug and use iPiMP to send some commands you'll see the requests/responses in the MediaPortal.log
 

Jarrod

Portal Member
May 17, 2005
8
0
Is there any documentation for the JSON protocol implementation that iPimp uses?
I too am setting up CommandFusion to control MediaPortal.

Side note: I am the Director of CommandFusion, so once I get this working I will be able to promote home automation integration with MP via iPad/iPhone/etc.
Use the one app to control MP as well as your lights, projector, receiver, blinds, etc.

Thanks,
 

DieBagger

Retired Team Member
  • Premium Supporter
  • September 11, 2007
    2,516
    1,276
    39
    Austria
    Home Country
    Austria Austria
    Hi Jarrod, I sent a pm with a similar to cheezey yesterday, here's the answer:

    I'm afraid I haven't documented the commands.

    The best option is to enable debug logging and run some commands through iPiMP, with debug logging on all requests/responses are logged. All requests/responses are in JSON format.

    The MPCC plugin provides TCP or HTTP listeners, the HTTP listener is probably better as it handles larger payloads better (e.g. images are transferred as Base64 strings which can be very large). You build your JSON request, HTTP POST it to the MPCC listener (http://<MPClient>:55668/mpcc) and consume the HTTP response.

    This file handles all the requests, you can see the available operations starting on line 448.

    cheezey: I ran it with ipimp/looked through the code, here's a few things I noticed:
    - The clientcontroller will crash mediaportal if fanarthandler plugin isn't installed and "nowplaying" is invoked
    - Their is no way to send continuous keypresses? It would be nice if there was a way to specify key-up/key-down commands, specially for scrolling through lists in mediaportal.
    - Why is the key value sent through "filter" in the "button" action, not in "value"? ;)

    More questions to come... ;)

    :D
     

    cheezey

    Community Plugin Dev
    August 26, 2004
    1,560
    312
    55
    West Yorks, UK
    Home Country
    United Kingdom United Kingdom
    - The clientcontroller will crash mediaportal if fanarthandler plugin isn't installed and "nowplaying" is invoked

    There is an updated MPCC plugin available here which had some fanart fixes in it.

    - Their is no way to send continuous keypresses? It would be nice if there was a way to specify key-up/key-down commands, specially for scrolling through lists in mediaportal.

    Not yet - shouldn't be too difficult to add though, how do you see this being used, you send a command for key-down and the plugin just keeps sending the key command until it receives a key up?

    - Why is the key value sent through "filter" in the "button" action, not in "value"? ;)

    Ahem :oops: because I'm not a dev by trade and when I first put the MPCC plugin together I knew nothing about JSON. I agree the plugin could do with refactoring such that it conforms to JSON-RPC.
     

    DieBagger

    Retired Team Member
  • Premium Supporter
  • September 11, 2007
    2,516
    1,276
    39
    Austria
    Home Country
    Austria Austria
    - Their is no way to send continuous keypresses? It would be nice if there was a way to specify key-up/key-down commands, specially for scrolling through lists in mediaportal.

    Not yet - shouldn't be too difficult to add though, how do you see this being used, you send a command for key-down and the plugin just keeps sending the key command until it receives a key up?

    Excactly, although I think it would be best to have a timeout, so after the client sends key down, the controller repeats the key press until a) client sends key up or b) timeout is reached (e.g. 500ms). If the client wants to scroll longer he needs to send continues key-ups (e.g. every 300ms). This way you don't waste bandwidth by sending a commands every 10ms and don't risk running an infinite-loop when client drops out. Btw, you have a Thread.Sleep(100) after sending a command. 100ms seems a bit excessive.

    btw @ Jarrod: for sending key commands you send a post request (has to have content-type application/x-www-form-urlencoded for some reason) with the following json data:

    Code:
    { 
     "action" : "button",
     "filter" : "left",
     "value" : "",
     "start" : "0",
     "pagesize" : "0",
     "shuffle" : false,
     "enqueue" : false,
     "tracks" : ""
    }

    to "http://server:55668/mpcc". Possible filter (button) values: Paste2: Next Generation Pastebin - Viewing Paste 1144201
     

    Jarrod

    Portal Member
    May 17, 2005
    8
    0

    Jarrod

    Portal Member
    May 17, 2005
    8
    0
    Ahh good to know. Now if only I could checkout the source code to the plugin so I can delve into it easier.
    The checkout link in the google code page 404's (both when typed onto a browser or used in TurtleSVN to checkout the code).
    Any ideas why I can't checkout the code?

    Further to that, trying to install the iPiMP plugin via the MP Extension Manager also fails (404).
     

    Users who are viewing this thread

    Top Bottom