redraw example XMPP stream with TikZ/PGF reviews final-after-review
authorRoland Hieber <rohieb@rohieb.name>
Fri, 17 Jan 2014 07:44:20 +0000 (08:44 +0100)
committerRoland Hieber <rohieb@rohieb.name>
Fri, 17 Jan 2014 07:44:20 +0000 (08:44 +0100)
fig-example-xmpp-stream.tex
sec-outlook.tex

index 15de658..13b13b1 100644 (file)
@@ -1,18 +1,51 @@
-\makeatletter \def\verbatim@font{\sffamily\scriptsize} \makeatother
+\tikzstyle{pkt}=[
+  fill,
+  below=-.5\baselineskip,
+  font=\scriptsize,
+  draw,
+  dash pattern=on 2pt off 2pt,
+]
+\tikzstyle{clipkt}=[pkt,
+  below left=-.5\baselineskip and 0cm,
+  pos=0.05,
+]
+\tikzstyle{devpkt}=[pkt,
+  below right=-.5\baselineskip and 0cm,
+  pos=0.05,
+]
+\begin{tikzpicture}[
+  every node/.style={fill=white, font=\small},
+  every picture/.style=ultra thin,
+  >=latex,
+  semithick
+]
 
-\begin{figure}[tp]
-  \small\centering
-\begin{tabular}{p{5cm}p{5cm}}
-Client to Device $\rightarrow$ & $\leftarrow$ Device to Client\\
+\def\bot{-16}
+\def\top{0}
+\def\dev{-5}
+\def\cli{5}
+\newlength{\ypos}
+\newlength{\yypos}
+\setlength{\ypos}{0cm}
+\setlength{\yypos}{.5cm}
+\def\advanceby#1{%
+  \addtolength{\ypos}{#1}%
+  \addtolength{\yypos}{#1}%
+  \global\ypos=\ypos% // see https://tex.stackexchange.com/questions/119730
+  \global\yypos=\yypos%
+}
 
-\begin{verbatim}
-<stream>
-\end{verbatim} & \\
+%% Header
+\draw (\cli,\top) node[draw]{Client} -- (\cli,\bot);
+\draw (\dev,\top) node[draw]{Device} -- (\dev,\bot);
 
- & \begin{verbatim}
-<stream>
-\end{verbatim} \\
+\advanceby{.75cm}
+\draw[->] (\cli,-\ypos) -- (\dev,-\yypos) node[clipkt]{\verb+<stream>+};
+\advanceby{1cm}
+\draw[->] (\dev,-\ypos) -- (\cli,-\yypos) node[devpkt]{\verb+<stream>+};
 
+\advanceby{1cm}
+\draw[->] (\cli,-\ypos) -- (\dev,-\yypos) node[clipkt,text width=5cm]{
 \begin{verbatim}
 <iq type='get' id='1'
     to='dev@device.local/res'
@@ -24,16 +57,25 @@ Client to Device $\rightarrow$ & $\leftarrow$ Device to Client\\
     <field name='Power'/>
   </req>
 </iq>
-\end{verbatim} & \\
+\end{verbatim}
+\advanceby{9\baselineskip}
+};
 
- & \begin{verbatim}<iq type='result' id='1'
+\advanceby{1cm}
+\draw[->] (\dev,-\ypos) -- (\cli,-\yypos) node[devpkt,text width=6cm]{
+\begin{verbatim}
+<iq type='result' id='1'
     from='dev@device.local'
     to='client@client.local/res'>
   <accepted xmlns='urn:xmpp:sn' seqnr='1'/>
 </iq>
-\end{verbatim} \\
+\end{verbatim}
+\advanceby{4\baselineskip}
+};
 
- & \begin{verbatim}
+\advanceby{1cm}
+\draw[->] (\dev,-\ypos) -- (\cli,-\yypos) node[devpkt,text width=7cm]{
+\begin{verbatim}
 <message from='dev@device.local'
     to='client@client.local/res'>
   <fields xmlns='urn:xmpp:sn' seqnr='1' done='true'>
@@ -47,17 +89,13 @@ Client to Device $\rightarrow$ & $\leftarrow$ Device to Client\\
     </node>
   </fields>
 </message>
-\end{verbatim} \\
-
-\begin{verbatim}
-</stream>
-\end{verbatim} & \\
+\end{verbatim}
+\advanceby{12\baselineskip}
+};
 
- & \begin{verbatim}
-</stream>
-\end{verbatim} \\
-\end{tabular}
-  \caption{Example XMPP stream with sensor data (XEP-0323)}
-  \label{fig:examplexmpp}
-\end{figure}
+\advanceby{1cm}
+\draw[->] (\cli,-\ypos) -- (\dev,-\yypos) node[clipkt]{\verb+</stream>+};
+\advanceby{1cm}
+\draw[->] (\dev,-\ypos) -- (\cli,-\yypos) node[devpkt]{\verb+</stream>+};
+\end{tikzpicture}
 % vim: set ft=tex et ts=2 sw=2 :
index 8e3eb6c..798634a 100644 (file)
@@ -38,7 +38,12 @@ for power and energy from the node named \emph{Device04}. The device first
 acknowledges this request, and, after retrieving the values, sends them back
 to the client. Afterwards, both sides close their streams.
 
-\input{fig-example-xmpp-stream.tex}
+\begin{figure}[h!]
+  \centering
+  \input{fig-example-xmpp-stream.tex}
+  \caption{Example XMPP stream with sensor data (XEP-0323)}
+  \label{fig:examplexmpp}
+\end{figure}
 
 \paragraph{Control (XEP-0325)~\cite{xep0325}} In this document, a way of
 controlling sensor nodes is specified, which allows a client to get and set
This page took 0.029991 seconds and 4 git commands to generate.