Cogito, ergo sum

Legacy:DatabaseConnection

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search

Quite often someone gets the idea to store information from an UnrealEngine game in a remote database for permanent and remote storage. The UnrealEngine does not provide any functions to directly communicate with a database. You will have to write your own interface for the communication.

While it is possible to write a driver that directly connects to the database server it might not always be the best thing to do. For a couple of reasons:

  • Security
    The database server should have an open connection to the world, this is not one of the smartest things to do.
  • Hosting limitations
    Often database server provided by hosting providers are out of your control to modify and usually only allow connections from certain servers.
  • Database portability
    You driver will only be able to communicate with one database server but not with an otherone, this can become a issue in the future.
  • Difficulty
    Usually it's not easy to write a database driver in UnrealScript because of it's limitations. Often databases require some crypto which is quite difficult to program from scratch in UnrealScript.
  • Performance
    UnrealScript isn't slow, but it surely isn't fast. For example crypto routines are usually not very fast in UnrealScript. And it's best to keep the performance of the game server as high as possible.

The better choise is to write a man-in-the-middle that will perform the actual communication with a database server. The unrealscript part will connect to the man-in-the-middle and will use an simple string based protocol that the man-in-the-middle will process (this protocol could simply be the direct SQL command). An example of a man-in-the-middle program is a webserver running a script (Perl\PHP\ASP\etc.). Or you could write a server application that does the same for you. Communication with the man-in-the-middle can be done by means of a TcpLink or UdpLink.

Note: when you use a webserver based implementation you might want to take a look at LibHTTP. It is HTTP client completely written in UnrealScript supporting most if not all features of the HTTP protocol. This might save you some time.

Related Forum Threads[edit]

Related Topics[edit]