Updated IPC documentation
[fmail.git] / docs / ipc.tex
blob1304a59df300abc3569caddd0f87a4df0c576eda
1 \documentclass{article}
3 \newcounter{paramc}
4 \newenvironment{paramlist}
5 {\begin{list}{\bfseries\upshape \hspace{2em}Parameter \arabic{paramc}:}
6 {\usecounter{paramc}\setlength{\parsep}{0.0ex}\setlength}}
7 {\end{list}}
9 \newcommand{\ipcmsg}[1]{{\raggedleft\bfseries\upshape #1}}
11 \begin{document}
13 \section{Conventions}
15 When describing the comunication examples between two process we will
16 define one process as a client (requesting a service) as the server,
17 the format to describe a message will be the following:
19 \begin{verbatim}
20 C: message name: parameter 1 ; parameter 2 ; parameter 3
21 S: message name: parameter 1 ; parameter 2 ; parameter 3
22 \end{verbatim}
24 Where C is client and S server.
26 \section{Common Messages}
28 \ipcmsg{ok}
30 A positive response to another mensage, should include a return value.
32 \begin{paramlist}
33 \item Return Value
34 \end{paramlist}
36 \ipcmsg{error}
38 An error message.
40 \begin{paramlist}
41 \item Message
42 \end{paramlist}
44 \section{Authentication Server}
45 \subsection{Messages}
47 \ipcmsg{verify}
49 Verify if a user exist, will return "ok" is the user
50 exist, error otherwise.
52 \begin{paramlist}
53 \item Username
54 \end{paramlist}
56 \ipcmsg{auth}
58 Will authenticate a given user, will return ok if the
59 user and password are right, error otherwise.
61 \begin{paramlist}
62 \item Username
63 \item Password
64 \end{paramlist}
66 \section{Mail Queue Server}
68 \subsection{Comunication Examples}
69 \subsubsection{Adding a message to a queue}
71 With a given queue named "incoming" we will push a message to it,
72 where C is the client and QS is the queue server:
74 \begin{verbatim}
75 C: slot: incoming
76 QS: ok: /tmp/fmain/queues/incoming/212214962143124030
77 C: push: incoming ; /tmp/fmain/queues/incoming/212214962143124030
78 QS: ok
79 \end{verbatim}
81 \subsubsection{Getting a message from a queue}
83 With a given queue named "incoming" we will pop a message from it,
84 where C is the client and QS is the queue server:
86 \begin{verbatim}
87 C: pop: incoming
88 QS: ok: /tmp/fmain/queues/incoming/212214962143124030
89 \end{verbatim}
91 \subsubsection{Subscribing to a queue}
93 With a given queue named "incoming" we will subscribe to it,
94 where C is the client and QS is the queue server:
96 \begin{verbatim}
97 C: subscribe: incoming ; socket://127.0.0.1:14001
98 QS: ok
99 \end{verbatim}
101 Once the client is subscribed and there is new messages in the queue,
102 the queue server will connect back to the client and send the message
103 "alert", then the client may pop messages till it receives the error
104 message:
106 \begin{verbatim}
107 QS: alert: incoming
108 C: pop: incoming
109 QS: ok: /tmp/fmain/queues/incoming/212214962143124030
110 C: pop: incoming
111 QS: error
112 \end{verbatim}
114 \subsection{Messages}
116 \ipcmsg{slot}
118 Request a slot from the message queue, it will send
119 back an OK response with the filename to use, this
120 filename will be the identifier the requested slot.
122 After writing the data into the file you must send back
123 a the finishing message "push", in order to move the
124 message to the queue.
126 \begin{paramlist}
127 \item Queue Name
128 \end{paramlist}
130 \ipcmsg{push}
132 Tell the queue server that it can move a given message to
133 the queue, this means that we finished writing the data to
134 the file and it is closed.
136 \begin{paramlist}
137 \item Queue Name
138 \item Filaname
139 \end{paramlist}
141 \ipcmsg{pop}
143 Retrieve the next message in the queue, it will return an OK
144 message with the filename.
146 \begin{paramlist}
147 \item Queue Name
148 \end{paramlist}
150 \ipcmsg{subscribe}
152 Subscribe to a message queue, the subscriber will receive alerts
153 when there is new messages in the queue.
155 \begin{paramlist}
156 \item Queue Name
157 \item IPC Callback String
158 \end{paramlist}
160 \ipcmsg{unsuscribe}
162 Remove subscription to a queue. The IPC Callback String should
163 be exactly the same as given on subscription.
165 \begin{paramlist}
166 \item Queue Name
167 \item IPC Callback String
168 \end{paramlist}
170 \section{Mailbox Server}
172 \subsection{Comunication Examples}
174 \subsubsection{Listing a user mailbox}
176 Give a mailbox server MS and a client C:
178 \begin{verbatim}
179 C: list: user_john
180 MS: ok: 2
181 MS: mailinfo: 1 ; 120
182 MS: mailinfo: 2 ; 300
183 MS: ok
184 \end{verbatim}
186 \subsection{Messages}
188 \ipcmsg{list}
190 It will return ok message with the amount of emails
191 for a given user, after that it will push n "mailinfo"
192 message. On failture it will return error.
194 \begin{paramlist}
195 \item Username
196 \end{paramlist}
198 \ipcmsg{mailinfo}
200 Return message with a given email detail.
202 \begin{paramlist}
203 \item Message Number
204 \item Message Size (in octets)
205 \end{paramlist}
207 \ipcmsg{store}
209 Store an email, it will return ok if successful and
210 begin using raw operations till read 'Data Length'
211 bytes.
213 \begin{paramlist}
214 \item To
215 \item Recipent
216 \item Data Length
217 \end{paramlist}
219 \ipcmsg{retr}
221 Retrieve an email for a given user. Should
222 return ok with the size of the email if the
223 email number is valid and then it will
224 start sending the email using raw operations.
225 If the email number is invalid will return error.
227 \begin{paramlist}
228 \item Username
229 \item Message Number
230 \end{paramlist}
232 \ipcmsg{dele}
234 Delete an email for a given user. It will return
235 ok if the operation was sucessful, error otherwise
236 (when the message doesen't exist.
238 \begin{paramlist}
239 \item Username
240 \item Message Number
241 \end{paramlist}
243 \end{document}