started with simple usage doc
This commit is contained in:
		| @@ -2,7 +2,7 @@ | |||||||
|  |  | ||||||
| #Additions | #Additions | ||||||
| - added changelog | - 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 "//removerights login" command | ||||||
| - added new EchoManager which handles Interactions between different Controllers | - 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 | 	- It is possible to send an Echo command via the Method sendEcho, as message Parameter strings, objects or arrays can get used | ||||||
|   | |||||||
| @@ -196,7 +196,7 @@ class SocketManager implements CallbackListener { | |||||||
| 					$buffer = ''; | 					$buffer = ''; | ||||||
| 					$connection->on('data', function ($data) use (&$buffer, &$connection) { | 					$connection->on('data', function ($data) use (&$buffer, &$connection) { | ||||||
| 						$buffer .= $data; | 						$buffer .= $data; | ||||||
| 						$arr = explode("\n", $buffer, 2); // much haxy. | 						$arr = explode("\n", $buffer, 2); | ||||||
| 						while (count($arr) == 2 && strlen($arr[1]) >= (int) $arr[0]) { | 						while (count($arr) == 2 && strlen($arr[1]) >= (int) $arr[0]) { | ||||||
| 							// received full message | 							// received full message | ||||||
| 							$len    = (int) $arr[0]; | 							$len    = (int) $arr[0]; | ||||||
|   | |||||||
							
								
								
									
										34
									
								
								core/Sockets/usage.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								core/Sockets/usage.txt
									
									
									
									
									
										Normal 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); | ||||||
|  | ?> | ||||||
		Reference in New Issue
	
	Block a user