Multicast control with PHP
From DISE KnowledgeBase
This article describes how to control Dise with simple multicast messages over the network.
Note that this is only an example. You can use this as a base for further development of your own control system.
All example code can be downloaded from the Remote Control from PHP entry in the download archive.
The example code is written in PHP but can easily be adapted to any system capable of sending UDP packages over the network.
Requirements
In order to run this example the following requirements must be met:
- Web server with PHP 5.0 or newer.
- For database access: MySQL 4.1 or newer. PHP needs to support the mysqli extension.
- If you are not using the database, you need write access to an ini-file in the script folder.
- You must have a working Dise setup with at least one Replay application.
- The web server needs to be on the same LAN segment as the Replay application or you need to set up multicast support in your network switches and routers.
You can use any modern operating system such as Windows XP, Windows Server 2003, BSD, Linux.
We recommend the following setup:
- Standard Windows or Linux computer.
- Apache 2.0.x. See: installation guide.
- PHP 5.2.x. See: installation guide.
- MySQL 5.1.x. Download from the MySQL website.
Installation
- Extract all files in the example code zip-file to a folder accessible for the web server. For example you can place them in a folder called dise in the web root folder.
- Open index.php in a text editor. If you don't want to use a MySQL database, change the contents on row 7 from: require_once('common/DataStore_MySQL.php'); to: require_once('common/DataStore_Text.php');
- If you are using MySQL add the following table to a database: CREATE TABLE DataStore (id VARCHAR(32) NOT NULL, data TEXT NOT NULL, PRIMARY KEY (id);
Make sure you have a valid user name and password and enter that in the config.php file.
- Make sure that the php_sockets extension is activated and that short_open_tag is set to On in php.ini
- Try out the installation by opening the index.php file in a web browser. For example if the scripts are placed in a folder called dise and you have a server installed locally on your computer, the URL would be: http://localhost/dise/index.php
- If there are any errors, check the Notes / Known problems section below.
Available functions
| Button |
A page that shows a button. When the button is clicked a message is sent. See function: Send
|
| Send |
Send a message over multicast. The data parameters holds the message to be sent.
|
| SetText |
Store a message in the database. The id parameter is the storage index and the data parameter contains the data that is to be saved.
|
| GetText |
Get a stored message. The id parameter tells which message to get.
|
Usage in a Dise system
These kind of messages can easily trigger scheduling on several levels in a Dise system.
Here are two examples of triggered channels that are shown transparent on top of the already playing content:
Goal: When we visit the URL http://localhost/dise/index.php?function=Button&data=Secret and click the button we want a message to appear on our screen.
- Design a small Dise movie in the Dise Composer that has a transparent background and the same resolution as the content that you already have put in Dise Bridge.
- Go into Dise Bridge and select the destination where you want to put this new triggered channel.
- Click on the Main Channel at the bottom left and then select Edit Channel > Add from the menu.
- Give this Channel a name and click OK.
- Add the Dise movie you made earlier to this new channel.
- Select the new Channel and select Edit Channel > Schedule from the menu.
- Go to the Misc tab and check the Remote Control group.
- As Trigger, specify the message that you want to use as a trigger. In this case Secret, but we also need to specify the source of the message, so in this case we should specify PHP|Secret.
- We can select how long this schedule is valid, leave it as 30 seconds and adjust it later.
- Click OK, send out the content and start the playback in Replay.
- Visit the URL above and press the button, this should send out the trigger and show the message.
Goal: When we visit the URL http://localhost/dise/index.php?id=Text, type a message and click Send we want the message we typed to appear on our screen.
- Design a small Dise Movie in the Dise Composer that has a transparent background and the same resolution as the content that you already have put in Dise Bridge.
- Add a text object that is data connected to http://localhost/dise/index.php?function=GetText&id=Text.
- In the Movie > Edit Movie Preferences. Change so that dependencies are downloaded every 1 second.
- Go into Dise Bridge and select the destination where you want to put this new triggered channel.
- Click on the Main Channel at the bottom left and then select Edit Channel > Add from the menu.
- Give this Channel a name and click OK.
- Add the Dise Movie you made earlier to this new channel.
- Select the new Channel and select Edit Channel > Schedule from the menu.
- Go to the Misc tab and check the Remote Control group.
- As Trigger, specify the message that you want to use as a trigger. In this case TEXT_Text, but we also need to specify the source of the message, so in this case we should specify PHP|TEXT_Text.
- We can select how long this schedule is valid, leave it as 30 seconds and adjust it later.
- Click OK, send out the content and start the playback in Replay.
- Visit the URL above, write some text and click Send, this should send out the trigger and show the message.
- If the text does not appear immediately then there might be a delay on transferring the text from the server, just change the Dise Movie to display the text a bit later in the time line.
Notes / Known problems
- If you are getting errors with DataStore_Text please check that the server has write access to the ini-file (usually called: datastore_text.ini).
- If you are getting errors with DataStore_MySQL please check the database settings in the config file.
- Problem: Dise does not receive my messages. Solution: Check the multicast IP address and port. Make sure the settings are the same in all the Replay applications. Also make sure the web server is on the same LAN segment or that the network equipment between the server and the replay computers are prepared for multicast usage. Also check your firewall and anti-virus settings. Try turning the firewall off.
- It is possible to view the multicast messages beeing received by any Replay application by selecting "Information / Remote Control View" from the Replay main window menu.
- If it is not possible to send multicast messages to the Player PCs you can use our Dise Complete Signals application to convert an UDP signal to multicast on the destination network. Contact us for more information on how to setup this.
- If you are using Apache on Windows, make sure you check this readme document.
Download: Example code