POT
POT
POT
Main menu

Download

Forum

SVN

Prev Next

OTAdmin client

POT contains simple implementation of OTAdmin protocol.

Table of Contents

OTAdmin protocol

OTAdmin protocol is a protocol that makes it possible to communicate directly with OTServ even remotely (however it has to be enabled) and to execute some commands. This protocol works directly within OTServ like all other protocols - login protocol, game protocol, info protocol etc. so it means it works on same port that all other OTServ services. It is binary protocol which is done using standard NetworkMessages (class that most OTServ-related projects in C++ use).

Encryption

For safety resons OTAdmin protocol can be encrypted. Encryption is not defined by protocol, only encryption interface is added into coded part so it means you can potentialy implement any encryption. However at the moment only one which is used is XTEA encryption with RSA-encrypted keys negotiation - it means that at first XTEA keys are transfered using RSA encryption and rest of connection is encrypted with XTEA using received keys. RSA key for negotation is stored on server, while XTEA key is always (usualy randomly) generated by client.

Encryption is automaticly detected and set by POT so in PHP you don't need to worry about anything connected with encryption. It's done internaly and mentioned only to give you a know.


Loggin in

Another safety enchantment is possiblity to enable password login required. As it requires you to put password, it can't be handled automaticly by POT - after connection you should check if password is required (after establishing connection all protocol flags are set).


Client API

POT implementation of OTAdmin protocol is complete (for current state of protocol development - it's still under development and at the moment provides only few commands):

  • login() - logs in with password.
  • ping() - checks if server is running.
  • broadcast() - sends broadcast message to all players.
  • close() - closes server (this command only closes server for game disabling new players to log in, server itself will still be running).
  • payHouses() - takes rent fees for all rented houses.
  • shutdown() - this command closes server physicly be shuting down it's process.
  • kick() - kicks given player from server.

Here is very simple example client session:

  1. <?php
  2.  
  3. // OTS_Admin class automaticly negotaites encryption, generates XTEA key and negotiates RSA encryption
  4. $admin new OTS_Admin('127.0.0.1');
  5.  
  6. // checks if server requires logging in
  7. if$admin->requiresLogin() )
  8. {
  9.     $admin->login('password');
  10. }
  11.  
  12. //commands examples:
  13.  
  14. // ping (in seconds)
  15. echo 'Server ping: '$admin->ping()' s'"\n";
  16.  
  17. // sends broadcast message to all players
  18. $admin->broadcast('Server is going down for maintenance');
  19.  
  20. // kicks player from server
  21. $admin->kick('Hurz');
  22.  
  23. // closes server for new connections - server is still running
  24. $admin->close();
  25.  
  26. // requests all rented houses to be paid on server
  27. $admin->payHouses();
  28.  
  29. // shuts server down - closes it physicly
  30. $admin->shutdown();
  31.  
  32. ?>

Curiosity: POT was the very first complete (for current protocol version) implementation of client API - it's version with the newest PAY_HOUSES command was released the day before oryginal OTAdmin tool!

Server save

Since saving and opening server is implemented in OTAdmin protocol and POT client for it, it is possible to evaluate full server-save cycle in a very simple way:

  1. <?php
  2.  
  3. // OTS_Admin class automaticly negotaites encryption, generates XTEA key and negotiates RSA encryption
  4. $admin new OTS_Admin('127.0.0.1');
  5.  
  6. /* put your login steps here */
  7.  
  8. // closes server for new connections - server is still running
  9. $admin->close();
  10.  
  11. // save current state
  12. $admin->save();
  13.  
  14. // open it again
  15. $admin->open();
  16.  
  17. ?>

Prev Up Next
Cache drivers POT Additional routines