Some doubts for WebSocket Server...
Hello guy's I have some doubts regarding the creation of my WebSocket Server and i wanns ask something to you :)

I'm creating an Server for Mobile application for write topics and comments (into mysql). Before i ask something i'll show toy my code /logic

1) This is my start_server.php. This is like "main" function and i use this for launch my server.
http://pastebin.com/kvcx8NzD

I realize an XML file for server settings and i load them with loadSettings. Now i think here it's all correct (i hope). Now i wanna try to use the IP Blacklist but i can't recognize how can i use it in this script :( and if you have some suggestion for improve this initial code please tell me.

2) The start_server create and lunch my server.php:
http://pastebin.com/nT3swRa5

Now in my server i have some objects:

clients: is original dataobject from test server (i think it will be removed)
router: is my special object, with this i route the request from client (i'll show after)
loop: is the main object loop, with this i send PINGs and prevent the connection close
users: is an array[email] dataset of clients object. with this i can reference the clients into my another classes

In the construnct i add an periodic function where i send PINGs and refresh the setting of server (min version for clients and another)

in onOpen event function i send an ACK to client ("Connected") and recognize (from IP for now) their location

in onMessage i decode the request from client exec the request (with data if the client send) with router (i'll show you after)

after exec the request i send the response (or ack) to the client.

in onClose i check if the client was logged in or not (in my $users)
if is logged i UNSET the position of my array (and i hope this free the memory)
else i remove only from clients and close connection (it's right?)

now it's correct for now or can i improve my script? (like memory usage or other)

NOW i'll show you my idea for manage the request of client, i created the MRC like pattern (Model Router Controller).

The logic is:   Client send Request (with controller, function and data if requested) ---> pass all to an Router Object ---> this check if exist that class of controller and that function, if exist create a new object of controller and run that function ----> this function comunicate with model for update data in database -----> return the response to router -----> router return response to client

Now this is my Router Class:
http://pastebin.com/GuQcaFkC

In the construct i add ONLY public controllers (i have some controllers only for server)

But this object it's really simply, now my doubt is on my Controller - Model logic.. Every time a client request something, the Router create a new Controller and every time a new Controller wad created, it create a private Model. Every time the model need to connect to Database, it create a new DB object for comunicate with DB (i'm using Medoo lib) and after all i REALLY HOPE the server release the memory and close all DB connection in auto. i tried to make an singleton DB object but i think isn't a good idea... so can you tell me (or teach ___) some improvements ? thx a lot and sorry for my bad english

Another problem is when Linux kill my php process after some days.. so i have edited the NICE value to 19 but when i run hTop and MySQLTuner i see this:

![test1](https://cloud.githubusercontent.com/assets/3913712/7513159/4d436234-f4b2-11e4-8613-619401f1854d.png)

![test2](https://cloud.githubusercontent.com/assets/3913712/7513163/54853a72-f4b2-11e4-9451-48dc1bc3ff73.png)

i see some mysqld process and i don't know if it's right or not
