Hi, I'll try and answer your questions as thoroughly as possible
- How complete is the script? Is it usable off the shelf?
> Yes, the script is complete, you can download it and run it off the shelf.
You can get the latest distribution build here:
http://code.google.com/p/smartsocket/downloads/detail?name=stable1.8.2.zip&can=1&q=
Alternatively you can build it from source:
http://github.com/XaeroDegreaz/SmartSocket/tree/master/PHP%20(Depreciated)/
- How stable is the script?
> Very.
- Is there any manual / example for basic usage?
> I can't remember where I put the phpdoc stuff I generated a long time ago, but There is an Example.php here :
http://github.com/XaeroDegreaz/SmartSocket/blob/master/PHP%20(Depreciated)/DIST/Extensions/Example/Example.php
I'll give you some good tutorial stuff at the end of this post.
- Is the compiling to exe a necessity? (I'd like to run on Linux)
[...]
> The distribution package I listed runs fine on Linux under WinE. Alternatively, if you want to make code changes, there is a build.sh shell script included in the source directory I linked above (Requires WinE).
- Known problems?
> PHP doesn't natively support multi threading, so if you are going to have a lot of data being sent at once from a lot of clients, it could bog down wile processing each send (using only one input and output thread). You could of course build the source ground up using the pcntl_fork library, but that only works when the exe is compiled under linux. You'd have to experiment with getting that working yourself. I tried getting it to work, but it was just too much of hassle. For this reason the PHP project was left in its stable form and was abandoned in favour of the new Java version.
Also, if you use the newer libmysql dll files, the console window will
hang for a few seconds when you try to close it. For this reason, I
think the distribution package comes with a little older version of
the dll file. You're free to switch out any extension or libraries you
see fit.
========
Now for some example code. Follow the premise of the Example.php in
the extensions dir. Each extension needs its own folder and same name
PHP file in the Extensions dir.
The base server doesn't care what kind of data you are sending back
and fourth. It could be JSON or XML or raw string. However, if your
extension class were to subclass one of the included extension in the
Extension dir (I reccommend SmartLobby if you are looking to use
multiplayer stuff) then you can call methods on the server like this:
(Be sure to read the comments in SmartLobby so that you understand how
to start up the server.)
Create a method on your extension:
class MyClass extends SmartLobby {
public function helloWorld($client, $xml) {
}
}
When you send <helloWorld someParam="someValue" /> to the server, your
helloWorld method will execute.
You can then echo($xml["someParam"]) and should get "someValue"
You can send data back to the client with $client->send( ). Depending
on how you are handling data on your client, what you send is up to
you; in the PHP version there is no outgoing data protocol.
In the SmartLobby extension, it also includes a basic Flash client
that uses the older version of the SmartLobby API, specifically
designed for XML.
===
I think that's about all that I can cover right now, if you have any
more questions feel free to shout.
Regards,
Jerome