RemoteAdmin:admin broadcast
From OpenSimulator
admin_broadcast remotely allows to broadcast a general alert to all agents in a region
Contents |
Enabling admin_broadcast
If not all functions are enabled, use admin_dbroadcast to enable the function in the [RemoteAdmin] section
enabled_methods = admin_broadcast,...
Parameters
Required Parameters
These parameters are required
parameter | Description | Values |
---|---|---|
message | Message to be broadcasted |
Optional Parameters
There are no optional parameters
Returned Parameters
Returned Parameters
These parameters are returned by Remote Admin
parameter | Description | Values |
---|---|---|
success | true when successfull | true, false |
error | error message when not successfull |
Error messages
No error Messages
Notes
- accepted is an optional returned parameter, probably used prior to success
Example
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); ?>
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'})
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
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"); } } }
Xml
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>
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>