alphacomm / alpharpc

AlphaRPC is an RPC daemon based on ZeroMQ that can be used to distribute workload over one or multiple servers.
alpharpc.net
BSD 3-Clause "New" or "Revised" License
2 stars 5 forks source link

Separate domain model from MessageSender/Reader #3

Open jacobkiers opened 10 years ago

jacobkiers commented 10 years ago

Currently it is pretty hard to test the code completely.

As the handlers have many dependencies, their construction is difficult.

In order to make stuff simpler we should make the domain model observable. The observer(s) should receive events and send it to the socket.

On the other side, no reading is done by the domain model, all messages are received via the onMessage() function.

An example:

<?php
$handler = new ClientHandler();
$observer = new ArrayStoreObserver($handler);
$handler->onMessage(new ClientRequestMessage());
print_r($observer->shiftMessage());

This should print an OK message.