redraw example XMPP stream with TikZ/PGF
[skm-ma-ws1314.git] / fig-example-xmpp-stream.tex
1 \tikzstyle{pkt}=[
2 fill,
3 below=-.5\baselineskip,
4 font=\scriptsize,
5 draw,
6 dash pattern=on 2pt off 2pt,
7 ]
8 \tikzstyle{clipkt}=[pkt,
9 below left=-.5\baselineskip and 0cm,
10 pos=0.05,
11 ]
12 \tikzstyle{devpkt}=[pkt,
13 below right=-.5\baselineskip and 0cm,
14 pos=0.05,
15 ]
16 \begin{tikzpicture}[
17 every node/.style={fill=white, font=\small},
18 every picture/.style=ultra thin,
19 >=latex,
20 semithick
21 ]
22
23 \def\bot{-16}
24 \def\top{0}
25 \def\dev{-5}
26 \def\cli{5}
27 \newlength{\ypos}
28 \newlength{\yypos}
29 \setlength{\ypos}{0cm}
30 \setlength{\yypos}{.5cm}
31 \def\advanceby#1{%
32 \addtolength{\ypos}{#1}%
33 \addtolength{\yypos}{#1}%
34 \global\ypos=\ypos% // see https://tex.stackexchange.com/questions/119730
35 \global\yypos=\yypos%
36 }
37
38 %% Header
39 \draw (\cli,\top) node[draw]{Client} -- (\cli,\bot);
40 \draw (\dev,\top) node[draw]{Device} -- (\dev,\bot);
41
42 \advanceby{.75cm}
43 \draw[->] (\cli,-\ypos) -- (\dev,-\yypos) node[clipkt]{\verb+<stream>+};
44 \advanceby{1cm}
45 \draw[->] (\dev,-\ypos) -- (\cli,-\yypos) node[devpkt]{\verb+<stream>+};
46
47 \advanceby{1cm}
48 \draw[->] (\cli,-\ypos) -- (\dev,-\yypos) node[clipkt,text width=5cm]{
49 \begin{verbatim}
50 <iq type='get' id='1'
51 to='dev@device.local/res'
52 from='client@client.local'>
53 <req xmlns='urn:xmpp:sn' seqnr='1'
54 momentary='true'>
55 <node nodeId='Device04'/>
56 <field name='Energy'/>
57 <field name='Power'/>
58 </req>
59 </iq>
60 \end{verbatim}
61 \advanceby{9\baselineskip}
62 };
63
64 \advanceby{1cm}
65 \draw[->] (\dev,-\ypos) -- (\cli,-\yypos) node[devpkt,text width=6cm]{
66 \begin{verbatim}
67 <iq type='result' id='1'
68 from='dev@device.local'
69 to='client@client.local/res'>
70 <accepted xmlns='urn:xmpp:sn' seqnr='1'/>
71 </iq>
72 \end{verbatim}
73 \advanceby{4\baselineskip}
74 };
75
76 \advanceby{1cm}
77 \draw[->] (\dev,-\ypos) -- (\cli,-\yypos) node[devpkt,text width=7cm]{
78 \begin{verbatim}
79 <message from='dev@device.local'
80 to='client@client.local/res'>
81 <fields xmlns='urn:xmpp:sn' seqnr='1' done='true'>
82 <node nodeId='Device04'>
83 <timestamp value='2013-03-07T22:03:15'>
84 <numeric name='Energy' momentary='true'
85 value='12345.67' unit='MWh'/>
86 <numeric name='Power' momentary='true'
87 value='239.4' unit='W'/>
88 </timestamp>
89 </node>
90 </fields>
91 </message>
92 \end{verbatim}
93 \advanceby{12\baselineskip}
94 };
95
96 \advanceby{1cm}
97 \draw[->] (\cli,-\ypos) -- (\dev,-\yypos) node[clipkt]{\verb+</stream>+};
98 \advanceby{1cm}
99 \draw[->] (\dev,-\ypos) -- (\cli,-\yypos) node[devpkt]{\verb+</stream>+};
100 \end{tikzpicture}
101 % vim: set ft=tex et ts=2 sw=2 :
This page took 0.063872 seconds and 5 git commands to generate.