I had a bit of a mess around and I had some comments. I know it's early in development and it's not finished, but here they are anyway.
- The packet initialization code is a little clunky. It would be nice if you could set packet properties in the constructor with optional parameters, so you could do something like this:
I tested PRISM 0.1.9 and it worked good.
Win7 32 and PHP 5.3.3
The autoini wizzard works super. very good idea
I have some questions
1: Is it posible (in future) to start the wizzard again to make changes (to add or remove Plugins) or to add or remover a server?
2: Is it posible (in future) to start or stop PRISM to one or more servers?
example: type !stop [ID of host] to stop PRISM on that host or type !start [ID of host] to start PRISM on that host
1) the wizard creates ini files in your PRISM/config/ folder which you can edit manually to change any config setting at any time. The wizard is primarily there for people who never ran PRISM before and 'just run it' without first reading up on configuration. They then get the chance to manually set it up. But I'd recommend everyone to first have a look at the config folder and the sample ini files in there. They provide a bit more insight tbh.
You can of course just delete the ini files in your config folder and then prism will fire off the wizard again. But editing the ini files directly is easier.
2) I'm not sure if starting stopping prism _through an LFS host_ can be done, or should be done. The best option to connect / disconnect hosts to / from prism is on prism's console window. You canot even give commands via an LFS host if it's not connected to prism, so that can be a bit pointless
first thought would be 'can add console commands', but then I remember stupid windows doesn't cooperate there
But, I had the thought of making a www admin page, where the admin can add / remove connections, plugins, etc and view status. That could be a nice solution i think.
Yeah, I agree on that point. But I can't do aliased or name arguments to give args out of order. The only thing I could do is hand the constructor a string and let it tokenized that (and to be frank, that's not great.) I've been thinking about this for quitesometime. Still no closer to an answer.
Yeah, I wanted to keep it simple for the plugin programmers. The sendPacket function knows what host sent the last packet, so when you send a packet back it knows what host to send it too. If you wanted to talk to another host tho, it's not currently possible, but I could add an arg to the sendPacket function that would allow that. The idea being that the plugin programmer should not have to think to much, for them PRISM's code does all of the heavy lifting and they can concentrate on making a great plugin.
- I'll fix that in the next release.
Yeah, I'm pretty lucky to have a lot of help . Thanks for the input, and for being gentle.
Yeah, I really don't plan on making an editor for the config files. I think the current system works very well. And if you should load a new plugin there should be enough examples within the config files already to help you edit it. If that's not what you wanted, delete the file and prism will make another one for you, and ask you what you want this time.
It's a planned future feature from my stand point. Both connections and plugins can be stoped, started, and paused.
Connections:
!prism stop - Sends a good bye packet, and ends the connection.
!prism start - Sends a hello packet (ISP_ISI) to a new host. (Client must be using this command for the PRISM console, or be in a sever they have admin RCON level admin privilege on, and be an admin on the server they wish to start PRISM on, with RCON level admin privileges there too.)
!prism pause - Same as pausing all plugins, will still maintain it's own internal connection and player arrays, and respond to pings (ISP_TINYs), but no plugins will get any packets. Twice to toggle.
Plugins
!prism plugin start <plugin> - Plugin included, and is loaded to accept packets from the current hosts. If done from console, should be asked what hosts to attach too. If done from in server will start on that server only. (Or if the plugin is already loaded on another server, plugin will start getting packets from this server.)
!prism plugin stop <plugin> - Plugin unloads, __destruct is called on the plugin (if available).
!prism plugin pause <plugin> - Plugin no longer gets any packets. Twice to toggle.
dygear, I think it's time you wrote that 'what is this' document and 'how it should work' because I think you are the only one who really knows atm
I get the feeling (and you said something to that extent on irc) that you want prism to be something that can be used by people who don't know a lot about programming. That's great of course, but through little hints here and there I get the feeling it's not going to be very interesting for the advanced programmers because while trying to keep it easy, you are also adding restrictions to what a plugin can do.
If I'd use prism because it has a decent core to build upon, I'd want full control over whatever I want to do with the hosts. I don't want to just send replies to hosts, but I want to be able to send anything I want to a host at any time!
So, that's why I'm asking for some docs on what prism should be and how it will work, schematically. Because then we can get a better picture of what's in your head and comment on it in order to improve on your ideas. Right now I'm not really sure what to say, apart from this post.
OK - I didn't realise PHP didn't support those sorts of optional parameters, the way that Python and C# 4.0 do. Seems rather strange to me that it doesn't.
Yeah, I hope that's not pissing to many people off. I guess I'll start to flesh out my ideas in this post.
I started off programming in 2004, and I can't believe that was almost 7 years ago, making simple plugins for AMX Mod that was at the time the de facto standard for administration and modification on Counter-Strike 1.5. AMX Mod came with a plugin interface via the SmallC programming language, SmallC is now known as PAWN by the way, providing a simple interface into the Counter-Strike engine provide by AMX Mod. So when a client would for example say something in the game, the plugin you wrote was notified by the callback mechanism within AMX Mod. AMX Mod would fire the SmallC function in your compiled code. AMX Mod also added an admin interface and admin commands into the mix. Along with the engine hooks this provided a very powerful interface into the Counter-Strike engine with little to no known of how the engine worked. It was event based programming at it's best. Something happens in the game, your code then get's called. Simple as that.
For the most part, that's all that mattered. You did not need to know about the underpinnings of the engine, you did not have to do pointer math, you did not even have to know what V-Tables where. All you had to do was find the callback for the event that you where looking for, and find the function that would get you the information you needed. These things combined make for a pretty easy way to program for AMX Mod, and for Counter-Strike.
With this in mind, I set out to make PRISM to AMX Mod of Live For Speed.
Prism will provide a admin interface in AMX Mod's footsteps, with some augmentation as PRISM can run on multiple servers at once.
It will provide a plugin interface that allows for hooking onto game based events.
It will do it's very best to keep it easy for the one programmer just starting out to program for just one server.
It will allow for advanced programmers to make whole systems within PRISM. Everything that the core has to leverage will be given to the programmer to so that they can expand on contract as they see for for their situation.
Where should I start with this? "Passage of a packet through PRISM?" Because I think you would be a better author of that post at this point. I could do an "Anatomy of a Packet Callback," or anything else that you think would be appropriate.
hmm no i think the connection part should not really be mentioned in the docs. That's transparent for the plugin writer basically.
I was thinking more of how-to docs for them, the plugin writers.
-How to start writing a plugin (the basic skeleton - the extending onto the plugins class)
-Registering a packet handler
-how to write packets to one or more hosts
-what NOT to do (eg. create your own 'main' loops inside a plugin)
and eventually all the methods a plugin can use
Then the more complete that doc gets along with time, the better the picture will be of what we can and cannot do with plugins.
Oh and (am I providing enough work for you?) the admin system could be laid out as well. Ppl will need to understand how that works, because it's way more than the regular admin or no admin situation.
<?php if ($M == '!thetime' OR $M == 'thetime' OR $M == '!time' OR $M == 'time') { $MTC = new IS_MTC(); $MTC->PLID = ($p->PLID) ? $p->PLID : NULL; $MTC->UCID = ($p->UCID) ? $p->UCID : NULL; $MTC->Msg = 'The time is: ' . date('H:i:s') . ' server local time'; $this->sendPacket($MTC); } ?>
<?php switch ($M) { case '!thetime': case 'thetime': case '!time': case 'time': $MTC = new IS_MTC(); $MTC->PLID = ($p->PLID) ? $p->PLID : NULL; $MTC->UCID = ($p->UCID) ? $p->UCID : NULL; $MTC->Msg = 'The time is: ' . date('H:i:s') . ' server local time'; $this->sendPacket($MTC); break;
owkay, got a http server running in prism.
It's not ready yet to be pulled into current - i have to run through a couple of things first to optimise a bit and check security, but you can see it at work here : http://vic.lfs.net:1800/
It just presents you with a form and it will print out all the POST values after you submit the form. You can also write GET values into the url and it'll show those as well.
Or in other words, this http server can at the moment parse and validate http requests, including parsing your GET and POST variables. It does not yet support cookies. Will work on that later, but it's break time now File uploads will prolly not work either yet - haven't tested. (as in, it'll probably reject your request. Obviously i know if a file would be saved or not )
I've pushed the new branch http to my repo for if anyone feels like checking it.
Still not finished (needs some extra work in the safety department), but I'm kinda done for today.
Cookies work now.