started with simple usage doc

This commit is contained in:
kremsy 2015-06-21 21:45:52 +02:00
parent 73ae826e44
commit a025211dfd
3 changed files with 36 additions and 2 deletions

View File

@ -2,7 +2,7 @@
#Additions
- added changelog
- added SocketManager which acts like a webserver you can connect to and interact with ManiaControl
- added SocketManager which acts like a communication interface you can connect to and interact with ManiaControl (also thanks to TGYoshi for some help)
- added "//removerights login" command
- added new EchoManager which handles Interactions between different Controllers
- It is possible to send an Echo command via the Method sendEcho, as message Parameter strings, objects or arrays can get used

View File

@ -196,7 +196,7 @@ class SocketManager implements CallbackListener {
$buffer = '';
$connection->on('data', function ($data) use (&$buffer, &$connection) {
$buffer .= $data;
$arr = explode("\n", $buffer, 2); // much haxy.
$arr = explode("\n", $buffer, 2);
while (count($arr) == 2 && strlen($arr[1]) >= (int) $arr[0]) {
// received full message
$len = (int) $arr[0];

34
core/Sockets/usage.txt Normal file
View File

@ -0,0 +1,34 @@
Ingame you can activate the Socket Manager and set Password and Port of it.
Sample Web Implementation
<?php
$errno = null;
$errstr = null;
$socket = fsockopen("xx.xxx.xx.xx", xxxxx, $errno, $errstr, 2);
echo "ok?" . $errno . " - " . $errstr . "\n";
$buff = '';
$data = array("method" => "getServerChat", "data" => "");
// Encode and Encrypt the Data
$data = json_encode(array("method" => "getServerChat", "data" => ""));
$data = openssl_encrypt($data, 'aes-192-cbc', 'YOUR_PASSWORD', OPENSSL_RAW_DATA, 'kZ2Kt0CzKUjN2MJX');
// Write the Data on the Socket
fwrite($socket, strlen($data) . "\n" . $data);
// Read Answer Data
$len = (int)fgets($socket);
echo $len;
while (!feof($socket) && strlen($buff) < $len) {
$buff .= fgets($socket, $len - strlen($buff) + 1);
}
// Decrypt and Decode the Response Data
$data = openssl_decrypt($buff, 'aes-192-cbc', 'YOUR_PASSWORD', OPENSSL_RAW_DATA, 'kZ2Kt0CzKUjN2MJX');
echo json_decode($data);
//Close the Socket
fclose($socket);
?>