matt protocol
[09/10/2008 21:42] marc allen
contents
introduction
The matt protocol describes a way to relay distreet messages between distributed network entities.
The matt protocol will be deployed in the final of the 18th annual Loebner Prize for Artifical Intelligence (Sunday October 12th).
protocol entities
There are three key entities in the matt protocol:
Mailbox
handles message storage and retrieval.
Participant
a network entity which requires the ability to send and receive messages with its peers.
Mediator
handles the assignment of a
Mailbox
to a
Participant
In order to start a matt session there must exist:
At least two
Participants
At least one
Mailbox
per
Participant
In order for network entities to communicate with each other:
Each
Participant
must
registerParticipant
with a
Mediator
A
Mediator
must ensure that each registered
Participant
is assigned a
Mailbox
Participants
perform
read
/
write
/
listen
operations on their respective
Mailboxes
protocol entity interfaces
The following outlines the operations that can be invoked on each of the entities describe above:
Mailbox
::empty()
: returns false if there are pending unread messages, otherwise true.
Mailbox
::active()
: returns true if mutable operations can be performed on the
Mailbox
Mailbox
::read()
: returns the first unread message in the
Mailbox
Mailbox
: writes a message to the
Mailbox
Mailbox
::addListener(
EventListner
)
: registers an
EventListner
with the
Mailbox
Mailbox
::removeListener()
: unregisters all
EventListners
EventListener
::onEvent(
EventType
,
String
)
: invoked by a
Mailbox
on each new event
Participant
: assigns a
Mailbox
to a
Participant
Mediator
::registerParticipant(
Participant
)
: registers a
Participant
with
Mediator
ice implementation
The following is the listing for a matt compliant api implemented using zeroc's ice:
#ifndef MATT_COMPONENTS_ICE_20080309_1545
#define MATT_COMPONENTS_ICE_20080309_1545
module
matt {
exception
MattException {
};
exception
MattNotActiveException
extends
MattException {
};
exception
MattNoMessageException
extends
MattException {
};
exception
MattListenException
extends
MattException {
};
exception
MattAlreadyListeningException
extends
MattListenException {
};
exception
MattNotListeningException
extends
MattListenException {
};
module
messaging {
enum
EventType {
Message,
Closed
};
class
EventListener {
void
onEvent(EventType event,
string
message);
};
class
Mailbox {
bool
empty();
bool
active();
string
read()
throws
MattNoMessageException,
MattNotActiveException;
void
write(
string
message)
throws
MattNotActiveException;
void
addListener(EventListener * listener)
throws
MattAlreadyListeningException,
MattListenException,
MattNotActiveException;
void
removeListener()
throws
MattNotListeningException,
MattListenException,
MattNotActiveException;
};
};
module
roles {
class
Participant {
void
setMailbox(matt::messaging::Mailbox * mb);
};
class
Mediator {
void
registerParticipant(Participant * p);
};
};
};
#endif
mediator
I will update this page with code for a mock
Mediator
shortly
examples
In the downloads section below I have added a tar containing the matt.ice file, a sample server/client implementation in C++ and the necessary files/projects to build these on Windows, Linux and Mac OSx.
In addition to the code.tar.gz file you will need to ensure that your platform has: Boost 1.35, gcc (linux/mac) or visual studio 2003 and Ice 3.2.1.
Setting up your environment.
Ensure the required software packages are installed (Boost, Ice, compiler).
untar the files (this will create a directory called "code").
On linux or mac, cd to the code directory and type "make"
On windows, open the visual studio project under code/exmaples/vc7
Running the smaple apps... the code generates two identical binaries, differing only in name called server.tsk/client.tsk on linux/mac and server.exe/client.exe on windows.
To run the server you must type:
$ ./server.[tsk|exe] --Ice.Config="/code/examples/config/server.cfg"
To run the client you must type:
$ ./client.[tsk|exe] --Ice.Config="/code/examples/config/client.cfg"
Note on linux/mac you can also cd in to the "exmaples/cpp" directory and type:
$ make run
This will start the server and client as required.
The sample server is very basic merely echoing back to a client what has been sent to it, an echo server if you will. It is not very robust and is only intended as a tool to develope client apps.
The sample client simply checks if there are any pending messages, if there are reads them, otherwise sends "hello".
If you have any problems please contact me. I am happy to extend these smaple apps if you have any addition requirements.
Please to not reply on the implementation of the sample server - it is a sample.
downloads
matt.ice interface file as specified above
cpp.tar.gz C++ binding
csharp.tar.gz C# binding
html.tar.gz documentation generated from matt.ice
java.tar.gz Java binding
matt.tar.gz interface file and Makefile which will create all bindings found on this page
python.tar.gz Python binding
vb.tar.gz Visual Basic binding
code.tar.gz Matt Implementation Code/Examples
noboost.tar.gz Matt Implementation Code/Examples
without Boost dependancy
withJavaClient.tar.gz Matt Implementation Code/Examples
with Java client
withJavaServer.tar.gz Matt Implementation Code/Examples
with Java client and Server
matt.exe Matt Implementation of client/server applicatiopns
FileRelayClient.exe Matt Implementation of FileRelay client/server applicatiopns
matt_bug_fix.exe Matt Implementation of client/server applicatiopns with GUI bug fix
q&a
How do I install Ice?
What do I do with the generated files, they are completely meaningless?
You need to extend the abstract class
matt::Participant
and implement the
setMailbox
member function.
You could also implement a
matt::messaging::EventListener
to have messages pushed to you, but this is optional
Can we have some comments in the code please?
Please look at the html download [or this page] for documentation.
I've got the API integrated, is there a
matt::Mediator
I can register with?
Ahh... I've not implemented one yet, I will do a Mock soon!
In the mean time you could repeat what you did
for the
matt::Mediator
and
matt::Mailbox
Admittedly, there's a little more code to these... but for the sake of proof of concept/mock returning a static
message or implementing an echo should be fine, no?
contact
If you have any questions please contact Marc Allen at:
matt@1bdi.co.uk
links
* This Ice file outlines the distributed components for a MATT session.
*
* TIG participants are required to implement the roles::Participant class,
* which is expected to implement the setMailbox method.
*
* Participants then have the option to either implementing an eventListener
* which requires an onEvent method to be implemented or to devise some method
* by which they poll a mailbox for new messages.
*
* Generated code for C++, C#, Java, Python and Visual Basic will be provided
* and arrangements to support other languages can be made.
*
* Sample code will also be provided for creating proxies to a Mediator.
*
* Usage:
*
* 1. Participant instances connect to a Mediator service
*
* 2. Once a sufficient number of Participants have register the Mediator will
* assign mailboxes to each
*
* 3. Once a Participant has a mailbox assigned they may begin:
* Read/Write Operations on that Mailbox until the Mailbox is closed.
* They may register an EventListener while the Mailbix is active.
*
* NOTE: A Mailbox may close for the following reasons:
* a. The allotted Time To Live (TTL) has been reached
* b. A registered EventListener fails to be responsive(*)
*
* 4. Once the Mailbox is closed/deactivated it will not be reopened.
*
* 5. Participants will have to re-register with a Mediator service in order
* to obtain a new Mailbox
*
* Please contact Marc Allen for more information: matt@1bdi.co.uk
*/