RemoteAdmin:admin broadcast
From OpenSimulator
(Difference between revisions)
JeffKelley (Talk | contribs) m (→PHP: Fixed broken Google Code link, replacing with internal page) |
|||
(10 intermediate revisions by 6 users not shown) | |||
Line 51: | Line 51: | ||
== Notes == | == Notes == | ||
− | *''accepted'' is an optional returned parameter, probably used prior to ''success'' | + | * ''accepted'' is an optional returned parameter, probably used prior to ''success'' |
== Example == | == Example == | ||
=== PHP === | === PHP === | ||
+ | This example needs the RemoteAdmin PHP Class file available [[RemoteAdmin:RemoteAdmin_Class|here]]. | ||
+ | |||
<source lang="php"> | <source lang="php"> | ||
<?php | <?php | ||
Line 71: | Line 73: | ||
</source> | </source> | ||
− | === Python | + | === Python === |
<source lang="python"> | <source lang="python"> | ||
Line 91: | Line 93: | ||
</source> | </source> | ||
− | [[ | + | === Example 2 - admin_broadcast - Python 3.6 === |
− | [[RemoteAdmin:Commands]] | + | |
+ | <source lang="python"> | ||
+ | #!/usr/bin/python3 | ||
+ | |||
+ | # admin_broadcast senden einer Nachricht an alle in einer Region. | ||
+ | # Python 3.6 - 21.04.2018 by Manfred Aabye | ||
+ | |||
+ | # Module laden | ||
+ | import xmlrpc.client | ||
+ | |||
+ | # Information | ||
+ | print('---------------------------------------------------------------------') | ||
+ | print('Setup: Opensim.ini - Del ; - ConsoleUser - ConsolePass') | ||
+ | print('---------------------------------------------------------------------') | ||
+ | print('Example:') | ||
+ | print('---------------------------------------------------------------------') | ||
+ | print('SimulatorAdress = http://127.0.0.1:9000/ or http://myserver.com:9000/') | ||
+ | print('ConsoleUser = Test') | ||
+ | print('ConsolePass = secret') | ||
+ | print('RegionMessage = This is a beautiful text on a beautiful day.') | ||
+ | print('---------------------------------------------------------------------') | ||
+ | |||
+ | # Abfragen | ||
+ | SimulatorAdress = input('SimulatorAdress:') | ||
+ | ConsoleUser = input('ConsoleUser:') | ||
+ | ConsolePass = input('ConsolePass:') | ||
+ | RegionMessage = input('RegionMessage:') | ||
+ | |||
+ | # Funktion admin_broadcast | ||
+ | def admin_broadcast(): | ||
+ | # Server Initialisieren | ||
+ | Simulator = xmlrpc.client.Server(SimulatorAdress) | ||
+ | # Password und Nachricht senden RegionMessage | ||
+ | Simulator.admin_broadcast({'password': ConsolePass, 'message': RegionMessage}) | ||
+ | |||
+ | # admin_broadcast Aufruf | ||
+ | admin_broadcast() | ||
+ | |||
+ | # Ende admin_broadcast | ||
+ | </source> | ||
+ | |||
+ | Example 2b OpenSimAdmin_Broadcast.py | ||
+ | |||
+ | <source lang="python"> | ||
+ | #!/usr/bin/python3 | ||
+ | # admin_broadcast senden einer Nachricht an alle in einer Region. | ||
+ | # Python 3.6 - 21.04.2018 by Manfred Aabye Version 0.3 | ||
+ | |||
+ | # import library | ||
+ | from appJar import gui | ||
+ | import xmlrpc.client | ||
+ | import configparser | ||
+ | |||
+ | def fehler(): | ||
+ | app.errorBox("Login Fehler", "Datenfehler") | ||
+ | |||
+ | def hilfe(): | ||
+ | app.infoBox("Hilfe", "Bitte Ihre Server Daten in die OpenSimAdmin.ini eintragen.") | ||
+ | |||
+ | # handle button events | ||
+ | def press(button): | ||
+ | if button == "Ende": | ||
+ | app.stop() | ||
+ | return | ||
+ | if button == "Hilfe": | ||
+ | hilfe() | ||
+ | return | ||
+ | if button == "Senden": | ||
+ | |||
+ | config = configparser.ConfigParser() | ||
+ | config.sections() | ||
+ | config.read('OpenSimAdmin.ini') | ||
+ | SimulatorAdress = config['DEFAULT']['SimulatorAdress'] | ||
+ | ConsoleUser = config['DEFAULT']['ConsoleUser'] | ||
+ | ConsolePass = config['DEFAULT']['ConsolePass'] | ||
+ | |||
+ | RegionMessage = app.getTextArea('RegionMessage') | ||
+ | print("SimulatorAdress:", SimulatorAdress, "ConsoleUser:", "RegionMessage:", RegionMessage) | ||
+ | # Server Initialisieren | ||
+ | Simulator = xmlrpc.client.Server(SimulatorAdress) | ||
+ | Simulator.admin_broadcast({'password': ConsolePass, 'message': RegionMessage}) | ||
+ | return | ||
+ | |||
+ | # create a GUI variable called app | ||
+ | app = gui("Admin Broadcast", "640x480") # Fenster erstellen mit Namen und Groesse | ||
+ | app.setFont(12) # Textgroesse | ||
+ | # add & configure widgets - widgets get a name, to help referencing them later | ||
+ | app.addLabel("title", "admin broadcast") # Textueberschrift im Fenster | ||
+ | # Abfragen | ||
+ | app.addTextArea("RegionMessage") | ||
+ | # link the buttons to the function called press | ||
+ | app.addButtons(["Senden", "Hilfe", "Ende"], press) | ||
+ | # start GUI | ||
+ | app.go() | ||
+ | |||
+ | </source> | ||
+ | |||
+ | OpenSimAdmin.ini | ||
+ | |||
+ | [DEFAULT] | ||
+ | SimulatorAdress = http://127.0.0.1:9000/ | ||
+ | ConsoleUser = Test | ||
+ | ConsolePass = secret | ||
+ | |||
+ | === C# === | ||
+ | |||
+ | This C# example is made as console project. | ||
+ | you need to use the XMLRPC.DLL that you can find in the opensim packadge. | ||
+ | |||
+ | <source lang="csharp"> | ||
+ | using System; | ||
+ | using System.Collections; | ||
+ | using System.Collections.Generic; | ||
+ | using System.Data; | ||
+ | using System.Linq; | ||
+ | using System.Text; | ||
+ | using Nwc.XmlRpc; | ||
+ | |||
+ | namespace ConsoleApplication1 | ||
+ | { | ||
+ | class Program | ||
+ | { | ||
+ | static void Main(string[] args) | ||
+ | { | ||
+ | var ht = new Hashtable(); | ||
+ | ht["password"] = "password"; | ||
+ | ht["message"] = "Hello World"; | ||
+ | var parameters = new List<Hashtable> { ht }; | ||
+ | var rpc = new XmlRpcRequest("admin_broadcast", parameters); | ||
+ | rpc.Invoke("http://127.0.0.1:9999"); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </source> | ||
+ | |||
+ | === Xml === | ||
+ | ==== Request ==== | ||
+ | <source lang="xml"> | ||
+ | <?xml version="1.0"?> | ||
+ | <methodCall> | ||
+ | <methodName>admin_broadcast</methodName> | ||
+ | <params> | ||
+ | <param> | ||
+ | <value> | ||
+ | <struct> | ||
+ | <member> | ||
+ | <name>password</name> | ||
+ | <value> | ||
+ | <string>abcd</string> | ||
+ | </value> | ||
+ | </member> | ||
+ | <member> | ||
+ | <name>message</name> | ||
+ | <value> | ||
+ | <string>test</string> | ||
+ | </value> | ||
+ | </member> | ||
+ | </struct> | ||
+ | </value> | ||
+ | </param> | ||
+ | </params> | ||
+ | </methodCall> | ||
+ | </source> | ||
+ | ==== Response ==== | ||
+ | <source lang="xml"> | ||
+ | <?xml version="1.0"?> | ||
+ | <methodResponse> | ||
+ | <params> | ||
+ | <param> | ||
+ | <value> | ||
+ | <struct> | ||
+ | <member> | ||
+ | <name>accepted</name> | ||
+ | <value> | ||
+ | <boolean>1</boolean> | ||
+ | </value> | ||
+ | </member> | ||
+ | <member> | ||
+ | <name>success</name> | ||
+ | <value> | ||
+ | <boolean>1</boolean> | ||
+ | </value> | ||
+ | </member> | ||
+ | </struct> | ||
+ | </value> | ||
+ | </param> | ||
+ | </params> | ||
+ | </methodResponse> | ||
+ | </source> | ||
+ | |||
+ | |||
+ | [[Category:RemoteAdmin]] | ||
+ | [[Category:RemoteAdmin Commands]] |
Latest revision as of 11:38, 16 March 2021
admin_broadcast remotely allows to broadcast a general alert to all agents in a region
Contents |
[edit] Enabling admin_broadcast
If not all functions are enabled, use admin_dbroadcast to enable the function in the [RemoteAdmin] section
enabled_methods = admin_broadcast,...
[edit] Parameters
[edit] Required Parameters
These parameters are required
parameter | Description | Values |
---|---|---|
message | Message to be broadcasted |
[edit] Optional Parameters
There are no optional parameters
[edit] Returned Parameters
[edit] Returned Parameters
These parameters are returned by Remote Admin
parameter | Description | Values |
---|---|---|
success | true when successfull | true, false |
error | error message when not successfull |
[edit] Error messages
No error Messages
[edit] Notes
- accepted is an optional returned parameter, probably used prior to success
[edit] Example
[edit] PHP
This example needs the RemoteAdmin PHP Class file available here.
<?php // Including the RemoteAdmin PHP class. include('RemoteAdmin.php'); // Instantiate the class with parameters identical to the Python example above $myRemoteAdmin = new RemoteAdmin('127.0.0.1', 9000, 'secret'); // Invoke admin_create_user (multiple parameters) $parameters = array('message' => 'Welcome in my region'); $myRemoteAdmin->SendCommand('admin_broadcast', $parameters); ?>
[edit] Python
# Author : DrScofield # Source : http://xyzzyxyzzy.net/2008/01/23/using-pythons-xmlrpclib-with-opensim/ # License : BSD License #!/usr/bin/python import xmlrpclib # XML-RPC URL (http_listener_port) simulatorUrl = "http://127.0.0.1:9000" # instantiate server object simulator = xmlrpclib.Server(simulatorUrl) # invoke admin_alert: requires password and message simulator.admin_broadcast({'password': 'secret', 'message': 'the answer is 42'})
[edit] Example 2 - admin_broadcast - Python 3.6
#!/usr/bin/python3 # admin_broadcast senden einer Nachricht an alle in einer Region. # Python 3.6 - 21.04.2018 by Manfred Aabye # Module laden import xmlrpc.client # Information print('---------------------------------------------------------------------') print('Setup: Opensim.ini - Del ; - ConsoleUser - ConsolePass') print('---------------------------------------------------------------------') print('Example:') print('---------------------------------------------------------------------') print('SimulatorAdress = http://127.0.0.1:9000/ or http://myserver.com:9000/') print('ConsoleUser = Test') print('ConsolePass = secret') print('RegionMessage = This is a beautiful text on a beautiful day.') print('---------------------------------------------------------------------') # Abfragen SimulatorAdress = input('SimulatorAdress:') ConsoleUser = input('ConsoleUser:') ConsolePass = input('ConsolePass:') RegionMessage = input('RegionMessage:') # Funktion admin_broadcast def admin_broadcast(): # Server Initialisieren Simulator = xmlrpc.client.Server(SimulatorAdress) # Password und Nachricht senden RegionMessage Simulator.admin_broadcast({'password': ConsolePass, 'message': RegionMessage}) # admin_broadcast Aufruf admin_broadcast() # Ende admin_broadcast
Example 2b OpenSimAdmin_Broadcast.py
#!/usr/bin/python3 # admin_broadcast senden einer Nachricht an alle in einer Region. # Python 3.6 - 21.04.2018 by Manfred Aabye Version 0.3 # import library from appJar import gui import xmlrpc.client import configparser def fehler(): app.errorBox("Login Fehler", "Datenfehler") def hilfe(): app.infoBox("Hilfe", "Bitte Ihre Server Daten in die OpenSimAdmin.ini eintragen.") # handle button events def press(button): if button == "Ende": app.stop() return if button == "Hilfe": hilfe() return if button == "Senden": config = configparser.ConfigParser() config.sections() config.read('OpenSimAdmin.ini') SimulatorAdress = config['DEFAULT']['SimulatorAdress'] ConsoleUser = config['DEFAULT']['ConsoleUser'] ConsolePass = config['DEFAULT']['ConsolePass'] RegionMessage = app.getTextArea('RegionMessage') print("SimulatorAdress:", SimulatorAdress, "ConsoleUser:", "RegionMessage:", RegionMessage) # Server Initialisieren Simulator = xmlrpc.client.Server(SimulatorAdress) Simulator.admin_broadcast({'password': ConsolePass, 'message': RegionMessage}) return # create a GUI variable called app app = gui("Admin Broadcast", "640x480") # Fenster erstellen mit Namen und Groesse app.setFont(12) # Textgroesse # add & configure widgets - widgets get a name, to help referencing them later app.addLabel("title", "admin broadcast") # Textueberschrift im Fenster # Abfragen app.addTextArea("RegionMessage") # link the buttons to the function called press app.addButtons(["Senden", "Hilfe", "Ende"], press) # start GUI app.go()
OpenSimAdmin.ini
[DEFAULT] SimulatorAdress = http://127.0.0.1:9000/ ConsoleUser = Test ConsolePass = secret
[edit] C#
This C# example is made as console project. you need to use the XMLRPC.DLL that you can find in the opensim packadge.
using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using Nwc.XmlRpc; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { var ht = new Hashtable(); ht["password"] = "password"; ht["message"] = "Hello World"; var parameters = new List<Hashtable> { ht }; var rpc = new XmlRpcRequest("admin_broadcast", parameters); rpc.Invoke("http://127.0.0.1:9999"); } } }
[edit] Xml
[edit] Request
<?xml version="1.0"?> <methodCall> <methodName>admin_broadcast</methodName> <params> <param> <value> <struct> <member> <name>password</name> <value> <string>abcd</string> </value> </member> <member> <name>message</name> <value> <string>test</string> </value> </member> </struct> </value> </param> </params> </methodCall>
[edit] Response
<?xml version="1.0"?> <methodResponse> <params> <param> <value> <struct> <member> <name>accepted</name> <value> <boolean>1</boolean> </value> </member> <member> <name>success</name> <value> <boolean>1</boolean> </value> </member> </struct> </value> </param> </params> </methodResponse>