![]() |
|
SageTV Studio Discussion related to the SageTV Studio application produced by SageTV. Questions, issues, problems, suggestions, etc. relating to the Studio software application should be posted here. |
![]() |
|
Thread Tools | Search this Thread | Display Modes |
#1
|
||||
|
||||
Client to Server Communication
I think i know the answer to this already, but it can't hurt to ask. Has anybody created a class that allows easy communication between a SageClient and the Sage server? I know I can use jetty to pass strings back and forth but that's a bit of work I'd like to avoid.
I'm not looking for anything fancy, just a simple way to pass a piece of data between a SageClient and the Sage server. Thanks, Tom
__________________
Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders. |
#2
|
||||
|
||||
Well, the simplest way is probably SetServerProperty, but then the server would have to poll the property periodically to see if it's changed. But if it doesn't change very often, and the server routinely reads it from the property file anyway, then that could be the best option.
If you need real-time two-way communication, with messages going back and forth continuously, then a TCP socket might be a good choice. You could also look at RMI, but I don't have any hands-on experience with that. I guess Jetty could work if you already have a dependency on it anyway, but it seems like overkill just for this. To some degree the choice is going to depend on what you're trying to accomplish and how frequent and responsive you need it to be.
__________________
-- Greg |
#3
|
|||
|
|||
You can pass it to the uicontext of clients from the server and I believe visa versa using SageTV.apiUI().
I have never used it but I have been told and believe it works like this. API call GetConnectedClients() will give you IDs (IP ![]() That is all from how Narflex explained it would work I believe. There is also the Ortus MQ (I believe that is the name it) but I have never used that either. Edit: Greg and I must have been posting at the same time ![]() |
#4
|
||||
|
||||
Thanks Greg and Plucky,
I don't want to execute widget code, so I think I will stay away from he UIContext approach. I'm working on the CommercialDetector plugin and there are two or three things that I need to co-ordinate between the server and the client: 1. If the SageClient requests comskip to be run on a MediaFile, I want it to pass a message to the server telling it to run comskip. I just need the the MediaFile ID so I could pass that as a String. I'd need a way to make sure the server received the info so another request by the client is not posted before the first one was picked up by the server. 2. I need a way to poll the server from a client to see if the server is processing a file. That's easy to do with a ServerProperty. 3. I need a way to poll the server to see if a particular file is being processed. That can easily be done using the ServerProperty as well. I suppose the easiest way will be to build some code to take care of item 1 using ServerProperty. Thanks, Tom
__________________
Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders. |
#5
|
||||
|
||||
Actually for that you might consider putting a custom "ComskipStatus" metadata property on the MediaFile itself using Get/SetMediaFileMetadata. So clients would mark MediaFiles for comskip processing, and the server would periodically do a FilterByMethod call to find MediaFiles that have been marked for processing, and change their status to "in progress" and then "completed" as appropriate. Clients can do a similar filtering call to display the processing queue. Seems to me this covers all your needs, although there are perhaps some synchronization issues to think about.
__________________
-- Greg |
#6
|
|||
|
|||
Definitely watch out for synchronization issues. If you don't think about this before starting, you'll get very confused, very quickly when things start going crazy on you.
__________________
Twitter: @ddb_db Server: Intel i5-4570 Quad Core, 16GB RAM, 1 x 128GB OS SSD (Win7 Pro x64 SP1), 1 x 2TB media drive Capture: 2 x Colossus STB Controller: 1 x USB-UIRT Software:Java 1.7.0_71; SageTV 7.1.9 Clients: 1 x HD300, 2 x HD200, 1 x SageClient, 1 x PlaceShifter Plugins: Too many to list now... |
#7
|
|||
|
|||
The ortus-mq plugin that I created uses JMS queueing to communicate between the various clients and servers. It uses events that you can can be sent to the server/clients/broadcast that can trigger methods similar to the Sage events. The plugin has a sample module for writing an event class. Let me know if you are interested, I can send you more info about it...
Thanks, Jeff |
#8
|
||||
|
||||
Thanks for all the feedback.
Jeff, yes I am interested in learning about your MQ plugin. I'll PM you my email address. Hopefully it is something easy to use, because all I need to do is create a FIFO queue of int's. I whipped up something that uses ServerProperty() but I'm worried about synchronization errors as Slugger pointed out. I made all of the methods that access or change the property synchronized, but I know that won't synchronize things across JVMs. Nothing I am doing is really critical. The worst thing that can happen is a file does not get an edl generated.
__________________
Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders. |
#9
|
||||
|
||||
I was thinking about this a little more last night and it occured to me that Sage already has the basic functionality built into the new sageEvent() plugin method. All we would need is a way to define new events instead of just the core events that are now available.
Does it make sense to suggest this to Sage?
__________________
Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders. |
#10
|
|||
|
|||
Quote:
Having sage do custom Listeners and the Fire Listeners api I could see causing more problems but would be a nice feature if people used it right. |
#11
|
|||
|
|||
You don't need MQ to do this, you can fire custom events with the Sage API already. The SageTVPluginRegistry.postEvent(String eventName, Map<String, Object> args) method is already there and can be used to post any kind of custom event. The only caveat is that eventName should not be the name of any defined core event (though this isn't enforced, from what I can tell, but will break/crash a lot of plugins and probably the core itself if one were to fire a custom event with the same name as a core event and not provide the expected args map). Also, the eventName shouldn't be the same as any other custom event fired by other plugins (and this definitely isn't enforced). To avoid these issues, I simply prefix my custom event names with my plugin id (i.e. all my custom events that are fired by SageAlert are prefixed with "SageAlert_"). Following that simple rule will avoid all the caveats listed above.
The other issue you may run into is I'm not sure if custom events fired by a client are propagated to the server. My gut tells me they're not, but I have never tried it. I'd be surprised if they were (unless the recent change to support this for media playback events in the core was a more general change to just fire all client events on the server as well).
__________________
Twitter: @ddb_db Server: Intel i5-4570 Quad Core, 16GB RAM, 1 x 128GB OS SSD (Win7 Pro x64 SP1), 1 x 2TB media drive Capture: 2 x Colossus STB Controller: 1 x USB-UIRT Software:Java 1.7.0_71; SageTV 7.1.9 Clients: 1 x HD300, 2 x HD200, 1 x SageClient, 1 x PlaceShifter Plugins: Too many to list now... |
#12
|
|||
|
|||
Well. Completely missed that in the API
![]() |
#13
|
|||
|
|||
Client, yes, but I'm not so sure a custom event fired by a client would also fire in the server's JVM. Someone would have to test that and report back (or Narflex could answer that as well). I've had no reason to experiment with that myself so I can't answer it one way or the other.
__________________
Twitter: @ddb_db Server: Intel i5-4570 Quad Core, 16GB RAM, 1 x 128GB OS SSD (Win7 Pro x64 SP1), 1 x 2TB media drive Capture: 2 x Colossus STB Controller: 1 x USB-UIRT Software:Java 1.7.0_71; SageTV 7.1.9 Clients: 1 x HD300, 2 x HD200, 1 x SageClient, 1 x PlaceShifter Plugins: Too many to list now... |
#14
|
|||
|
|||
I asked that same question to Sage, and they said it only fired in the JVM that the post method was executed in...
Thanks, Jeff |
#15
|
|||
|
|||
Was this before or after the recent change in 7.0.12 that fired the media playback events from the client into the server's JVM as well? I guess what I'm wondering is if that change/fix was just for those three core events or was the change more generic such that all client events are now propagated to the server's JVM? My gut says it's the former, but that's purely speculation on my part.
__________________
Twitter: @ddb_db Server: Intel i5-4570 Quad Core, 16GB RAM, 1 x 128GB OS SSD (Win7 Pro x64 SP1), 1 x 2TB media drive Capture: 2 x Colossus STB Controller: 1 x USB-UIRT Software:Java 1.7.0_71; SageTV 7.1.9 Clients: 1 x HD300, 2 x HD200, 1 x SageClient, 1 x PlaceShifter Plugins: Too many to list now... |
#16
|
|||
|
|||
I don't really recall the version when I had posted the question to Sage. I haven't tried the custom posting of events, but I know from the debug logging in the ortus-mq plugin, that majority of the plugins either fire on the server or client and haven't noticed many that fired on both. I guess we would have to propose the question to Sage again if that has changed.
Thanks, Jeff |
#17
|
||||
|
||||
Last night I tried creating my own event to see if firing it on the client would fire it on the server. Nope. I'm running 7.0.15.
Tom
__________________
Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders. |
#18
|
|||
|
|||
Kind of figured it'd be that way... if the values of the arg map were mandated to be serializable then adding this support wouldn't be too bad, but since that's not the case, it's no trivial task to serialize the map from the client across to the server JVM. There are other ways to get events across to the server though (MQ, Jetty, etc.). Though the Sage API would be by far the easiest/most intuitive for most plugin devs.
__________________
Twitter: @ddb_db Server: Intel i5-4570 Quad Core, 16GB RAM, 1 x 128GB OS SSD (Win7 Pro x64 SP1), 1 x 2TB media drive Capture: 2 x Colossus STB Controller: 1 x USB-UIRT Software:Java 1.7.0_71; SageTV 7.1.9 Clients: 1 x HD300, 2 x HD200, 1 x SageClient, 1 x PlaceShifter Plugins: Too many to list now... |
#19
|
||||
|
||||
Quote:
It wouldn't be trivial for Sage to implement, but even if the API only allowed a small number data types, all of which must be serializable, having a built in Sage server to Sage Client mechanism would be VERY useful. Tom
__________________
Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders. |
#20
|
|||
|
|||
Quote:
![]()
__________________
Twitter: @ddb_db Server: Intel i5-4570 Quad Core, 16GB RAM, 1 x 128GB OS SSD (Win7 Pro x64 SP1), 1 x 2TB media drive Capture: 2 x Colossus STB Controller: 1 x USB-UIRT Software:Java 1.7.0_71; SageTV 7.1.9 Clients: 1 x HD300, 2 x HD200, 1 x SageClient, 1 x PlaceShifter Plugins: Too many to list now... |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
most common cause of communication problems? | tvmaster2 | SageTV Media Extender | 9 | 04-19-2010 10:46 AM |
Sage losing communication with HDPVRs | srothwell | Hardware Support | 5 | 03-18-2010 09:59 AM |
Developing STV for Client and CLient on Server machine | antplugger | SageTV Studio | 2 | 03-30-2006 05:09 PM |
SageClient server communication | dZeus | SageTV Studio | 2 | 01-06-2006 05:50 PM |
W/PVR250 in client can client remote control server? | mdmint | General Discussion | 8 | 05-01-2004 07:33 PM |