views:

203

answers:

2

Hello, i have a continously running Serverprogram (C#/.NET 2.0 on Linux with mono) and i want to connect to it from a PHP Script to display status informations on a WebSite.

The purpose is to create a (sort-of) Realtime Browsergame (No Flash, no Silverlight) and i want to use the PHP Script to get the necessary informations from the C# GameServer, i.e. current unit positions, player resources, score, visible map, etc. Informations update every second or even faster but actions might take hours or even days (i.e. research might take a week to complete)

Are there any libraries which allow me to easily transfer informations between those two parts of the program?

My thoughts:

  • Use an embedded WebServer and connect via PHPs SoapClient.
    Does anyone have experience with a free embedded WebServer (free because the Game will be free)?

  • Socket Programming and transfer chunks of JSON/XML/SOAP.
    Are there any simple libraries for this type of network communication for PHP/C# that automatically reads from the socket until the message is done and then i.e. sends an event to the game controller?

  • Simply Dump per-user and global Data into a Database or into xml files
    Easiest solution but imho not scaleable enough.

What would you suggest?

Thanks in advance.

Addition for others having a similar Question:

After a little more research after posting this Question i stumbled upon the .NET System.Net.HttpListener which is even supported by mono so i will use this now. It seems to have everything required to embed an WebServer into your running Server.


+1  A: 

Just run a simple server on the C# server, connect to it from your client (PHP) via a socket. You'll have to write the "rules" for interaction, but you can avoid the overhead that comes with JSON/SOAP, etc. Another solution is to use an XMLRPC server.

Andrew Sledge
Are there any (good and free) libraries for this? I'd prefer not to write the whole socket stuff as it can be quite complex (checking for dropped connections, timeouts, async reading/writing, multiple parallel connections, ...) and it's not in the scope of what i really want to create for this project.
dbemerlin
+1  A: 

I would use a simple embedded webserver and just use the PHP Curl extentions to interact with it http://php.net/manual/en/book.curl.php. For the embedded webserver I'd start looking on codeplex e.g. http://www.codeplex.com/webserver.

Hannes de Jager
Do you know an embedded webserver that is easy to integrate? I only found http://www.codeplex.com/webserver and that one seems to have far too many options to still count as "simple" and it might be overkill for this project.
dbemerlin
Maybe this stackoverflow link helps http://stackoverflow.com/questions/458036/create-simple-embedded-http-and-https-applications-in-c, I see mention is made of this embedded server there also: http://runkayak.com/
Hannes de Jager
http://runkayak.com/ really looks easy to use.
Hannes de Jager
Thanks, looks like what i need.
dbemerlin