SlideShare a Scribd company logo
 
規格 RFC2779: IM requirements RFC3920: XMPP Core RFC3921: XMPP IM & Presence XEP-0030: Service Discovery XEP-0045: Multi-User Chat 沢山あるけど,基本はこんな感じ
JID 各パーツは 1023B 以下 “ @ “ とか “ / “ とかも含めて 3071B 以下 IPv4address / IPv6address = address-literal ( internationalized domain label ) = sub-domain ( sub-domain 1 * ( “ . “  sub-domain ) ) = fqdn fqdn / address-literal = domain [ node “ @ ” ] domain [ “ / ” resource ] = jid
メッセージ転送 ( client / server ) JID の to 属性の hostname がサーバ名と一致 to 属性に書かれた JID が以下の場合 < user @ example . com > < user @ example . com / resource > < user @ example . com > < user @ example . com / resouce > 一致するアカウントがなければ無視,もしくはエラー 一致するリソースがなければ presense:  無視 iq:  エラー message: < user @ domain > と同様の処理 リソースが複数ある場合( message の場合) プライオリ値最大のリソースに配信 priority 宣言がなければ 0 相当 priority が負の場合には配信禁止
メッセージ転送 ( server / server ) _xmpp-server . _tcp . example . com  で DNS を検索 _im . < proto > . example . com  で DNS を検索(  IM  の場合) _pres . < proto > . example . com  で DNS を検索(  presence, iq  の場合) DNS で A レコードを検索して, TCP 5269  にアクセス(サーバ間通信) サーバクライアント間通信の場合,サーバが使うのは  TCP 5222
セッション TCP TLS SASL Resource Binding ( user @ domain / resource ) クライアント サーバ < session / > < message / >, < presence / > option メッセージの やりとりをする までに必要な 設定
message syntax < message type = “ chat “ / > < message type = “ error “ / > < message type = “ groupchat “ / > < message type = “ headline “ / > 配信やブロードキャストで使用 < message type = “ normal “ / > type  で何も指定していなかったり,理解できない指定があった場合に適用 message の子要素は option 以下の要素は namespace を指定せずに使用可 < message >< subject / >< / message > < message >< body / >< / message > < message >< thread / >< / message >
IQ ( Info / Query ) syntax Requesting Entity Responding Entity < iq type = ‘ get ‘ id = ‘ 1 ‘ > < iq type = ‘ result ‘ id = ‘ 1 ‘ > < iq type = ‘ set ‘ id = ‘ 2 ‘ > < iq type = ‘ error ‘ id = ‘ 2 ‘ > type 属性は4 種類 理由がない限り必須 id 属性も理由がない限り必須
Psi2OpenFire  (設定) Psi  の設定 Connection proxy: None Compress traffic: No Send &quot;keep-alive&quot; packets: Yes Manually Specify Server Host/Port: No Encrypt connection: When available Ignore SSL warnings: No ←  こうすると,エラーが出て来るけど continue する Probe legacy SSL port: No ←  ここを No にすると明示的に TLS を使う Allow plaintext authentication: Never XML Console を開くと,赤字で C2S ストリーム,黄字で S2C ストリーム表示 OpenFire はほぼ Default 設定で,ユーザを一人分設定
Psi2OpenFire ( TLS 開設まで) -- C2S— <?xml version=&quot;1.0&quot;?> <stream:stream xmlns:stream=&quot;http://etherx.jabber.org/streams&quot; version=&quot;1.0&quot; xmlns=&quot;jabber:client&quot; to=&quot;foo.hoge.co.jp&quot; xml:lang=&quot;en&quot; xmlns:xml=&quot;http://www.w3.org/XML/1998/namespace&quot; > -- S2C -- <?xml version='1.0' encoding='UTF-8'?> <stream:stream xmlns:stream=&quot;http://etherx.jabber.org/streams&quot; xmlns=&quot;jabber:client&quot; from=&quot;foo.hoge.co.jp&quot; id=&quot;b9a694d9&quot; xml:lang=&quot;en&quot; version=&quot;1.0&quot;> -- S2C -- -- TLS による通信要求  -- <stream:features> <starttls xmlns=&quot;urn:ietf:params:xml:ns:xmpp-tls&quot;/> <mechanisms xmlns=&quot;urn:ietf:params:xml:ns:xmpp-sasl&quot;> <mechanism>PLAIN</mechanism> <mechanism>CRAM-MD5</mechanism> <mechanism>ANONYMOUS</mechanism> <mechanism>DIGEST-MD5</mechanism> </mechanisms> <compression xmlns=&quot;http://jabber.org/features/compress&quot;> <method>zlib</method> </compression> <auth xmlns=&quot;http://jabber.org/features/iq-auth&quot;/> <register xmlns=&quot;http://jabber.org/features/iq-register&quot;/> </stream:features> -- C2S -- -- TLS による通信開始  -- <starttls xmlns=&quot;urn:ietf:params:xml:ns:xmpp-tls&quot;/> -- S2C -- --  サーバが TLS 開始を確認  -- <proceed xmlns=&quot;urn:ietf:params:xml:ns:xmpp-tls&quot;/> よくみると,サーバは一度に要求 してるが,クライアントはひとつずつ 応えている
セッション TCP TLS SASL Resource Binding ( user @ domain / resource ) クライアント サーバ < session / > < message / >, < presence / > option メッセージの やりとりをする までに必要な 設定
Psi2OpenFire ( SASL 開設まで) -- C2S -- -- TLS による通信開始  -- <?xml version=&quot;1.0&quot;?> <stream:stream xmlns:stream=&quot;http://etherx.jabber.org/streams&quot; version=&quot;1.0&quot; xmlns=&quot;jabber:client&quot; to=&quot;foo.hoge.co.jp&quot; xml:lang=&quot;en&quot; xmlns:xml=&quot;http://www.w3.org/XML/1998/namespace&quot; > -- S2C -- --  サーバからの応答開始  -- <?xml version='1.0' encoding='UTF-8'?> <stream:stream xmlns:stream=&quot;http://etherx.jabber.org/streams&quot; xmlns=&quot;jabber:client&quot; from=&quot;foo.hoge.co.jp&quot; id=&quot;b9a694d9&quot; xml:lang=&quot;en&quot; version=&quot;1.0&quot;> -- S2C -- -- SASL 要求  -- <stream:features> <mechanisms xmlns=&quot;urn:ietf:params:xml:ns:xmpp-sasl&quot;> <mechanism>PLAIN</mechanism> <mechanism>CRAM-MD5</mechanism> <mechanism>ANONYMOUS</mechanism> <mechanism>DIGEST-MD5</mechanism> </mechanisms> <compression xmlns=&quot;http://jabber.org/features/compress&quot;> <method>zlib</method> </compression> <auth xmlns=&quot;http://jabber.org/features/iq-auth&quot;/> <register xmlns=&quot;http://jabber.org/features/iq-register&quot;/> </stream:features> -- C2S -- <auth xmlns=&quot;urn:ietf:params:xml:ns:xmpp-sasl“ mechanism=&quot;DIGEST-MD5&quot; /> -- S2C -- <challenge xmlns=&quot;urn:ietf:params:xml:ns:xmpp-sasl&quot;>...</challenge> -- C2S -- --  クライアントがレスポンスを送信  -- <response xmlns=&quot;urn:ietf:params:xml:ns:xmpp-sasl&quot;>...</response> -- S2C -- --  サーバが認証成功宣言  -- <success xmlns=&quot;urn:ietf:params:xml:ns:xmpp-sasl&quot;>...</success> GTalk は SSL を使ってるので TLS での通信要求はでない
セッション TCP TLS SASL Resource Binding ( user @ domain / resource ) クライアント サーバ < session / > < message / >, < presence / > option メッセージの やりとりをする までに必要な 設定
Psi2OpenFire (圧縮モード設定まで) -- C2S -- -- SASL ベースで再度アクセス  -- <?xml version=&quot;1.0&quot;?> <stream:stream xmlns:stream=&quot;http://etherx.jabber.org/streams&quot; version=&quot;1.0&quot; xmlns=&quot;jabber:client&quot; to=&quot;foo.hoge.co.jp&quot; xml:lang=&quot;en&quot; xmlns:xml=&quot;http://www.w3.org/XML/1998/namespace&quot; > -- S2C -- --  サーバ応答  -- <?xml version='1.0' encoding='UTF-8'?> <stream:stream xmlns:stream=&quot;http://etherx.jabber.org/streams&quot; xmlns=&quot;jabber:client&quot; from=&quot;foo.hoge.co.jp&quot; id=&quot;b9a694d9&quot; xml:lang=&quot;en&quot; version=&quot;1.0&quot;> -- S2C -- -- traffic を圧縮するかどうかを確認してる  -- -- Psi で &quot;Compress traffic&quot; にチェックしてないので無反応  -- <stream:features> <compression xmlns=&quot;http://jabber.org/features/compress&quot;> <method>zlib</method> </compression> <bind xmlns=&quot;urn:ietf:params:xml:ns:xmpp-bind&quot;/> <session xmlns=&quot;urn:ietf:params:xml:ns:xmpp-session&quot;/> </stream:features>
Psi2OpenFire ( Roster 取得まで) -- C2S -- -- Client asks server to bind a resource: -- -- RFC3920 7. Resource Binding -- <iq type=&quot;set&quot; id=&quot;bind_1&quot; > <bind xmlns=&quot;urn:ietf:params:xml:ns:xmpp-bind&quot;> <resource>Psi</resource> </bind> </iq> -- S2C -- -- Server informs client of successful resource binding: -- -- RFC3920 7. Resource Binding -- <iq xmlns=&quot;jabber:client&quot; type=&quot;result&quot; id=&quot;bind_1&quot; to=&quot;foo.hoge.co.jp/b9a694d9&quot; > <bind xmlns=&quot;urn:ietf:params:xml:ns:xmpp-bind&quot;> <jid> daiba@foo.hoge.co.jp/Psi </jid> </bind> </iq> -- C2S -- -- Client requests session with server: -- -- RFC3921 3. Session Establishment -- <iq type=&quot;set&quot; id=&quot;aab5a&quot; > <session xmlns=&quot;urn:ietf:params:xml:ns:xmpp-session&quot;/> </iq> -- S2C -- --Server informs client that session has been created -- --  この段階で &quot;active resource&quot; としてサーバに登録された  -- <iq type=&quot;result&quot; id=&quot;aab5a&quot; to=&quot;daiba@foo.hoge.co.jp/Psi&quot; > <session xmlns=&quot;urn:ietf:params:xml:ns:xmpp-session&quot;/> </iq> -- C2S -- -- Client requests current roster from server: -- -- 7.3. Retrieving One's Roster on Login -- <iq type=&quot;get&quot; id=&quot;aab6a&quot; > <query xmlns=&quot;jabber:iq:roster&quot;/> </iq> -- S2C -- -- Client receives roster from server: -- <iq type=&quot;result&quot; id=&quot;aab6a&quot; to=&quot;daiba@foo.hoge.co.jp/Psi&quot; > <query xmlns=&quot;jabber:iq:roster&quot;/> </iq> resource  ってのは, [email_address]  / Psi  の “  Psi “  の部分
Psi2OpenFire ( Priority 設定まで) -- C2S -- -- Presence priority: -- -- RFC3921 5.4. Specifying Presence Priority -- <presence> <priority>5</priority> <c xmlns=&quot;http://jabber.org/protocol/caps&quot; node=&quot;http://psi-im.org/caps&quot; ver=&quot;0.11-dev-rev8&quot; ext=&quot;cs ep-notify html&quot; /> </presence>
Psi2GoogleTalk ( Roster 取得) -- C2S -- -- Client requests current roster from server: -- -- 7.3. Retrieving One's Roster on Login -- <iq type=&quot;get&quot; id=&quot;aab6a&quot; > <query xmlns=&quot;jabber:iq:roster&quot;/> </iq> -- S2C -- -- Client receives roster from server: -- <iq type=&quot;result&quot; to=&quot;daibak@gmail.com/griffin9EB3DE9D&quot; id=&quot;aab6a&quot; > <query xmlns=&quot;jabber:iq:roster&quot;> <item subscription=“both” name=“ 誰か &quot; jid=“noname@gmail.com&quot; /> <item subscription=&quot;both&quot; jid=&quot;twitter@twitter.com&quot; /> <item subscription=&quot;both&quot; jid=&quot;jaiku@jaiku.com&quot; > <group>Buddies</group> </item> </query> </iq>
Psi2GoogleTalk ( vCard 取得) -- C2S -- -- vCard Action: Resulting Stanza -- -- XEP-0054 6.2 URI Query Types -- <iq type=&quot;get&quot; to=&quot;daibak@gmail.com&quot; id=&quot;aab9a&quot; > <vCard xmlns=&quot;vcard-temp“ version=&quot;2.0“ prodid=&quot;-//HandGen//NONSGML vGen v1.0//EN&quot; /> </iq> <iq from= [email_address] type=&quot;result“ to=daibak@gmail.com/griffin9EB3DE9D id=&quot;aab9a&quot; > <vCard xmlns=&quot;vcard-temp&quot;> <FN>Keiichi daiba</FN> <PHOTO> <TYPE>image/jpeg</TYPE> <BINVAL>...</BINVAL> </PHOTO> </vCard> </iq> バイナリデータをBasa64? 変換して埋め込んである
Psi2GoogleTalk (メッセージ送受信) -- BOT  にメッセージを送る  -- <message type=&quot;chat&quot; to=&quot;en2ja@bot.talk.google.com&quot; id=&quot;aabea&quot; > <body>general</body> <active xmlns=&quot;http://jabber.org/protocol/chatstates&quot;/> </message> <message from=&quot;en2ja@bot.talk.google.com&quot; type=&quot;chat&quot; to=&quot;daibak@gmail.com/griffinEB79CC3A&quot; > <body> 全般 </body> </message>
Psi2OpenFire (ルーム作成) -- C2S -- --  チャットルーム作成  -- <presence to=&quot;test@ conference .foo.hoge.co.jp/test&quot; > <priority>0</priority> <x xmlns=&quot;http://jabber.org/protocol/muc&quot;> <history maxchars=&quot;0&quot; /> </x> </presence> -- S2C – --  成功  -- <presence from=test@conference.foo.hoge.co.jp/test to=“daiba@foo.hoge.co.jp/Psi&quot; > <priority>0</priority> <x xmlns=&quot;http://jabber.org/protocol/muc#user&quot;> <item affiliation=&quot;owner“ role=&quot;moderator“ jid=“daiba@foo.hoge.co.jp/Psi&quot; /> <status code=&quot;201&quot; /> </x> </presence> “  conference “  は  OpenFire  のデフォルト設定 ルーム名 “  test “ ,ニックネームも “  test “ -- C2S -- <iq type=&quot;set&quot; to=&quot;test@conference.foo.hoge.co.jp&quot; id=&quot;aac1a&quot; > <query xmlns=&quot;http://jabber.org/protocol/muc#owner&quot;> <x xmlns=&quot;jabber:x:data&quot; type=&quot;submit&quot; /> </query> </iq> -- S2C – <message from=test@conference.foo.hoge.co.jp type=&quot;groupchat“ to=“daiba@foo.hoge.co.jp/Psi&quot; > <body> This room is locked from entry until configuration is confirmed. </body> </message> <message from=test@conference.foo.hoge.co.jp type=&quot;groupchat“ to=“daiba@foo.hoge.co.jp/Psi&quot; > <body>This room is now unlocked.</body> </message> 作成した状態ではLOCKされてるので submit してUNLOCK
Psi2OpenFire (設定確認) -- C2S -- --  設定確認 – <iq from=‘daiba@foo.hoge.co.jp/Psi' id='config1' to='test@conference.foo.hoge.co.jp' type='get'> <query  xmlns='http://jabber.org/protocol/muc#owner'/> </iq> -- S2C -- --  確認したデータ  -- <iq from=test@conference.foo.hoge.co.jp type=&quot;result“ id=&quot;config1“ to=“daiba@foo.hoge.co.jp/Psi&quot; > <query xmlns=&quot;http://jabber.org/protocol/muc#owner&quot;> <x xmlns=&quot;jabber:x:data&quot; type=&quot;form&quot; > <title>Room configuration</title> <instructions>...</instructions> <field type=&quot;hidden&quot; var=&quot;FORM_TYPE&quot; > <value>http://jabber.org/protocol/muc#roomconfig</value> </field> <field type=&quot;text-single“ label=&quot;Room Name“ var=&quot;muc#roomconfig_roomname&quot; > <value>test</value> </field> ... <field type=&quot;list-single“ label=&quot;Maximum Room Occupants“ var=&quot;muc#roomconfig_maxusers&quot; > <value>30</value> <option label=&quot;10&quot; > <value>10</value> </option> <option label=&quot;20&quot; > <value>20</value> </option> <option label=&quot;30&quot; > <value>30</value> </option> <option label=&quot;40&quot; > <value>40</value> </option> <option label=&quot;50&quot; > <value>50</value> </option> <option label=&quot;None&quot; > <value>0</value> </option> </field> ... </x> </query> </iq> 初期設定で, 参加可能な人数は30 パラメータを何も 指定しないとすべての 設定を返す
Psi2OpenFire (設定変更) --  設定変更  -- -- C2S -- <iq from=‘daiba@foo.hoge.co.jp/Psi' id='create2' to='test@conference.foo.hoge.co.jp' type='set'> <query xmlns='http://jabber.org/protocol/muc#owner'> <x xmlns='jabber:x:data' type='submit'> <field var='muc#roomconfig_maxusers'> <value>0</value> </field> </x> </query> </iq> -- S2C -- <iq from=test@conference.turk.nttr.co.jp type=&quot;result“ id=&quot;create2“ to=“daiba@foo.hoge.co.jp/Psi&quot; /> Psi  の XML コンソールを使って手動で XML 送信 < value > 0 < / value >  が最大入室無制限

More Related Content

PPTX
20171005 告白に学ぶ http status code
PPTX
XMPPの紹介
PPTX
XMPPクライアント・プログラミング
PDF
Javaパフォーマンスチューニング基礎
ODP
Message delivery over XMPP network
ODP
Transports on XMPP network
PDF
Global azure boot camp 2015 in japan 妖怪はみた!実録 Azure事件簿
PDF
JAZUG5周年総会 仮想マシンの?(ハテナ)を試す
20171005 告白に学ぶ http status code
XMPPの紹介
XMPPクライアント・プログラミング
Javaパフォーマンスチューニング基礎
Message delivery over XMPP network
Transports on XMPP network
Global azure boot camp 2015 in japan 妖怪はみた!実録 Azure事件簿
JAZUG5周年総会 仮想マシンの?(ハテナ)を試す

Viewers also liked (20)

PDF
Evolution of Public Relations Through Content Marketing - Congreso PRORP
PPTX
Convergence: Social Media SEO Content Marketing SES Chicago 2011
PPTX
Content Marketing Strategy - The Future is Bright for Web Content
PPS
Classics
PPS
The butterfly_The flower
PDF
Create Demand and Influence with Co-Created Content for B2B Marketing
PPS
prova tre
PDF
Erlang with Regexp Perl And Port
PPTX
Content Marketing - How to Optimize & Socialize for Better Performance
PDF
Atom Pub
PDF
[Erlang LT] Regexp Perl And Port
PPTX
Content Marketing Optimization - TopRank Marketing
PPTX
#Optimize Content & Customers - Search Congress Barcelona
PPT
Drupal101
PDF
Web-Scale Discovery: Post Implementation
PPTX
Optimized Blogging That Inspires Action
PPS
PPTX
Optimize & Socialize for Better Business Blogging
PDF
Amazon Ec2
Evolution of Public Relations Through Content Marketing - Congreso PRORP
Convergence: Social Media SEO Content Marketing SES Chicago 2011
Content Marketing Strategy - The Future is Bright for Web Content
Classics
The butterfly_The flower
Create Demand and Influence with Co-Created Content for B2B Marketing
prova tre
Erlang with Regexp Perl And Port
Content Marketing - How to Optimize & Socialize for Better Performance
Atom Pub
[Erlang LT] Regexp Perl And Port
Content Marketing Optimization - TopRank Marketing
#Optimize Content & Customers - Search Congress Barcelona
Drupal101
Web-Scale Discovery: Post Implementation
Optimized Blogging That Inspires Action
Optimize & Socialize for Better Business Blogging
Amazon Ec2
Ad

Similar to XMPP仕様簡単解説 (20)

PPTX
HTML5でセマンティックなマークアップ
PPT
Keynote In Japanese
PPT
Struts2を始めよう!
PPT
実社会で進められているサービスとLOD
ODP
webを飾る技術
PDF
MT meets PHP
PDF
MT meets PHP - PHP conference Kansai 2013
ODP
日常業務にperlを使おう
PPT
Module02
PDF
HTML仕様書を読んでみよう
PPT
2008.10.18 L4u Tech Talk
PPT
Ruby on Rails Tutorial Chapter8-10
PPT
PHP, Now and Then 2011
PPT
JavaScript&Firebug入門
PPT
Code Igniterについて
PPT
エンジニア知識共有会発表資料 20090910
PDF
Inside Movable Type
PPTX
Let's make your CDN with RUBY
PPTX
URLで遊ぼう
PPTX
Perl logging
HTML5でセマンティックなマークアップ
Keynote In Japanese
Struts2を始めよう!
実社会で進められているサービスとLOD
webを飾る技術
MT meets PHP
MT meets PHP - PHP conference Kansai 2013
日常業務にperlを使おう
Module02
HTML仕様書を読んでみよう
2008.10.18 L4u Tech Talk
Ruby on Rails Tutorial Chapter8-10
PHP, Now and Then 2011
JavaScript&Firebug入門
Code Igniterについて
エンジニア知識共有会発表資料 20090910
Inside Movable Type
Let's make your CDN with RUBY
URLで遊ぼう
Perl logging
Ad

XMPP仕様簡単解説

  • 1.  
  • 2. 規格 RFC2779: IM requirements RFC3920: XMPP Core RFC3921: XMPP IM & Presence XEP-0030: Service Discovery XEP-0045: Multi-User Chat 沢山あるけど,基本はこんな感じ
  • 3. JID 各パーツは 1023B 以下 “ @ “ とか “ / “ とかも含めて 3071B 以下 IPv4address / IPv6address = address-literal ( internationalized domain label ) = sub-domain ( sub-domain 1 * ( “ . “ sub-domain ) ) = fqdn fqdn / address-literal = domain [ node “ @ ” ] domain [ “ / ” resource ] = jid
  • 4. メッセージ転送 ( client / server ) JID の to 属性の hostname がサーバ名と一致 to 属性に書かれた JID が以下の場合 < user @ example . com > < user @ example . com / resource > < user @ example . com > < user @ example . com / resouce > 一致するアカウントがなければ無視,もしくはエラー 一致するリソースがなければ presense: 無視 iq: エラー message: < user @ domain > と同様の処理 リソースが複数ある場合( message の場合) プライオリ値最大のリソースに配信 priority 宣言がなければ 0 相当 priority が負の場合には配信禁止
  • 5. メッセージ転送 ( server / server ) _xmpp-server . _tcp . example . com で DNS を検索 _im . < proto > . example . com で DNS を検索( IM の場合) _pres . < proto > . example . com で DNS を検索( presence, iq の場合) DNS で A レコードを検索して, TCP 5269 にアクセス(サーバ間通信) サーバクライアント間通信の場合,サーバが使うのは TCP 5222
  • 6. セッション TCP TLS SASL Resource Binding ( user @ domain / resource ) クライアント サーバ < session / > < message / >, < presence / > option メッセージの やりとりをする までに必要な 設定
  • 7. message syntax < message type = “ chat “ / > < message type = “ error “ / > < message type = “ groupchat “ / > < message type = “ headline “ / > 配信やブロードキャストで使用 < message type = “ normal “ / > type で何も指定していなかったり,理解できない指定があった場合に適用 message の子要素は option 以下の要素は namespace を指定せずに使用可 < message >< subject / >< / message > < message >< body / >< / message > < message >< thread / >< / message >
  • 8. IQ ( Info / Query ) syntax Requesting Entity Responding Entity < iq type = ‘ get ‘ id = ‘ 1 ‘ > < iq type = ‘ result ‘ id = ‘ 1 ‘ > < iq type = ‘ set ‘ id = ‘ 2 ‘ > < iq type = ‘ error ‘ id = ‘ 2 ‘ > type 属性は4 種類 理由がない限り必須 id 属性も理由がない限り必須
  • 9. Psi2OpenFire (設定) Psi の設定 Connection proxy: None Compress traffic: No Send &quot;keep-alive&quot; packets: Yes Manually Specify Server Host/Port: No Encrypt connection: When available Ignore SSL warnings: No ← こうすると,エラーが出て来るけど continue する Probe legacy SSL port: No ← ここを No にすると明示的に TLS を使う Allow plaintext authentication: Never XML Console を開くと,赤字で C2S ストリーム,黄字で S2C ストリーム表示 OpenFire はほぼ Default 設定で,ユーザを一人分設定
  • 10. Psi2OpenFire ( TLS 開設まで) -- C2S— <?xml version=&quot;1.0&quot;?> <stream:stream xmlns:stream=&quot;http://etherx.jabber.org/streams&quot; version=&quot;1.0&quot; xmlns=&quot;jabber:client&quot; to=&quot;foo.hoge.co.jp&quot; xml:lang=&quot;en&quot; xmlns:xml=&quot;http://www.w3.org/XML/1998/namespace&quot; > -- S2C -- <?xml version='1.0' encoding='UTF-8'?> <stream:stream xmlns:stream=&quot;http://etherx.jabber.org/streams&quot; xmlns=&quot;jabber:client&quot; from=&quot;foo.hoge.co.jp&quot; id=&quot;b9a694d9&quot; xml:lang=&quot;en&quot; version=&quot;1.0&quot;> -- S2C -- -- TLS による通信要求 -- <stream:features> <starttls xmlns=&quot;urn:ietf:params:xml:ns:xmpp-tls&quot;/> <mechanisms xmlns=&quot;urn:ietf:params:xml:ns:xmpp-sasl&quot;> <mechanism>PLAIN</mechanism> <mechanism>CRAM-MD5</mechanism> <mechanism>ANONYMOUS</mechanism> <mechanism>DIGEST-MD5</mechanism> </mechanisms> <compression xmlns=&quot;http://jabber.org/features/compress&quot;> <method>zlib</method> </compression> <auth xmlns=&quot;http://jabber.org/features/iq-auth&quot;/> <register xmlns=&quot;http://jabber.org/features/iq-register&quot;/> </stream:features> -- C2S -- -- TLS による通信開始 -- <starttls xmlns=&quot;urn:ietf:params:xml:ns:xmpp-tls&quot;/> -- S2C -- -- サーバが TLS 開始を確認 -- <proceed xmlns=&quot;urn:ietf:params:xml:ns:xmpp-tls&quot;/> よくみると,サーバは一度に要求 してるが,クライアントはひとつずつ 応えている
  • 11. セッション TCP TLS SASL Resource Binding ( user @ domain / resource ) クライアント サーバ < session / > < message / >, < presence / > option メッセージの やりとりをする までに必要な 設定
  • 12. Psi2OpenFire ( SASL 開設まで) -- C2S -- -- TLS による通信開始 -- <?xml version=&quot;1.0&quot;?> <stream:stream xmlns:stream=&quot;http://etherx.jabber.org/streams&quot; version=&quot;1.0&quot; xmlns=&quot;jabber:client&quot; to=&quot;foo.hoge.co.jp&quot; xml:lang=&quot;en&quot; xmlns:xml=&quot;http://www.w3.org/XML/1998/namespace&quot; > -- S2C -- -- サーバからの応答開始 -- <?xml version='1.0' encoding='UTF-8'?> <stream:stream xmlns:stream=&quot;http://etherx.jabber.org/streams&quot; xmlns=&quot;jabber:client&quot; from=&quot;foo.hoge.co.jp&quot; id=&quot;b9a694d9&quot; xml:lang=&quot;en&quot; version=&quot;1.0&quot;> -- S2C -- -- SASL 要求 -- <stream:features> <mechanisms xmlns=&quot;urn:ietf:params:xml:ns:xmpp-sasl&quot;> <mechanism>PLAIN</mechanism> <mechanism>CRAM-MD5</mechanism> <mechanism>ANONYMOUS</mechanism> <mechanism>DIGEST-MD5</mechanism> </mechanisms> <compression xmlns=&quot;http://jabber.org/features/compress&quot;> <method>zlib</method> </compression> <auth xmlns=&quot;http://jabber.org/features/iq-auth&quot;/> <register xmlns=&quot;http://jabber.org/features/iq-register&quot;/> </stream:features> -- C2S -- <auth xmlns=&quot;urn:ietf:params:xml:ns:xmpp-sasl“ mechanism=&quot;DIGEST-MD5&quot; /> -- S2C -- <challenge xmlns=&quot;urn:ietf:params:xml:ns:xmpp-sasl&quot;>...</challenge> -- C2S -- -- クライアントがレスポンスを送信 -- <response xmlns=&quot;urn:ietf:params:xml:ns:xmpp-sasl&quot;>...</response> -- S2C -- -- サーバが認証成功宣言 -- <success xmlns=&quot;urn:ietf:params:xml:ns:xmpp-sasl&quot;>...</success> GTalk は SSL を使ってるので TLS での通信要求はでない
  • 13. セッション TCP TLS SASL Resource Binding ( user @ domain / resource ) クライアント サーバ < session / > < message / >, < presence / > option メッセージの やりとりをする までに必要な 設定
  • 14. Psi2OpenFire (圧縮モード設定まで) -- C2S -- -- SASL ベースで再度アクセス -- <?xml version=&quot;1.0&quot;?> <stream:stream xmlns:stream=&quot;http://etherx.jabber.org/streams&quot; version=&quot;1.0&quot; xmlns=&quot;jabber:client&quot; to=&quot;foo.hoge.co.jp&quot; xml:lang=&quot;en&quot; xmlns:xml=&quot;http://www.w3.org/XML/1998/namespace&quot; > -- S2C -- -- サーバ応答 -- <?xml version='1.0' encoding='UTF-8'?> <stream:stream xmlns:stream=&quot;http://etherx.jabber.org/streams&quot; xmlns=&quot;jabber:client&quot; from=&quot;foo.hoge.co.jp&quot; id=&quot;b9a694d9&quot; xml:lang=&quot;en&quot; version=&quot;1.0&quot;> -- S2C -- -- traffic を圧縮するかどうかを確認してる -- -- Psi で &quot;Compress traffic&quot; にチェックしてないので無反応 -- <stream:features> <compression xmlns=&quot;http://jabber.org/features/compress&quot;> <method>zlib</method> </compression> <bind xmlns=&quot;urn:ietf:params:xml:ns:xmpp-bind&quot;/> <session xmlns=&quot;urn:ietf:params:xml:ns:xmpp-session&quot;/> </stream:features>
  • 15. Psi2OpenFire ( Roster 取得まで) -- C2S -- -- Client asks server to bind a resource: -- -- RFC3920 7. Resource Binding -- <iq type=&quot;set&quot; id=&quot;bind_1&quot; > <bind xmlns=&quot;urn:ietf:params:xml:ns:xmpp-bind&quot;> <resource>Psi</resource> </bind> </iq> -- S2C -- -- Server informs client of successful resource binding: -- -- RFC3920 7. Resource Binding -- <iq xmlns=&quot;jabber:client&quot; type=&quot;result&quot; id=&quot;bind_1&quot; to=&quot;foo.hoge.co.jp/b9a694d9&quot; > <bind xmlns=&quot;urn:ietf:params:xml:ns:xmpp-bind&quot;> <jid> daiba@foo.hoge.co.jp/Psi </jid> </bind> </iq> -- C2S -- -- Client requests session with server: -- -- RFC3921 3. Session Establishment -- <iq type=&quot;set&quot; id=&quot;aab5a&quot; > <session xmlns=&quot;urn:ietf:params:xml:ns:xmpp-session&quot;/> </iq> -- S2C -- --Server informs client that session has been created -- -- この段階で &quot;active resource&quot; としてサーバに登録された -- <iq type=&quot;result&quot; id=&quot;aab5a&quot; to=&quot;daiba@foo.hoge.co.jp/Psi&quot; > <session xmlns=&quot;urn:ietf:params:xml:ns:xmpp-session&quot;/> </iq> -- C2S -- -- Client requests current roster from server: -- -- 7.3. Retrieving One's Roster on Login -- <iq type=&quot;get&quot; id=&quot;aab6a&quot; > <query xmlns=&quot;jabber:iq:roster&quot;/> </iq> -- S2C -- -- Client receives roster from server: -- <iq type=&quot;result&quot; id=&quot;aab6a&quot; to=&quot;daiba@foo.hoge.co.jp/Psi&quot; > <query xmlns=&quot;jabber:iq:roster&quot;/> </iq> resource ってのは, [email_address] / Psi の “ Psi “ の部分
  • 16. Psi2OpenFire ( Priority 設定まで) -- C2S -- -- Presence priority: -- -- RFC3921 5.4. Specifying Presence Priority -- <presence> <priority>5</priority> <c xmlns=&quot;http://jabber.org/protocol/caps&quot; node=&quot;http://psi-im.org/caps&quot; ver=&quot;0.11-dev-rev8&quot; ext=&quot;cs ep-notify html&quot; /> </presence>
  • 17. Psi2GoogleTalk ( Roster 取得) -- C2S -- -- Client requests current roster from server: -- -- 7.3. Retrieving One's Roster on Login -- <iq type=&quot;get&quot; id=&quot;aab6a&quot; > <query xmlns=&quot;jabber:iq:roster&quot;/> </iq> -- S2C -- -- Client receives roster from server: -- <iq type=&quot;result&quot; to=&quot;daibak@gmail.com/griffin9EB3DE9D&quot; id=&quot;aab6a&quot; > <query xmlns=&quot;jabber:iq:roster&quot;> <item subscription=“both” name=“ 誰か &quot; jid=“noname@gmail.com&quot; /> <item subscription=&quot;both&quot; jid=&quot;twitter@twitter.com&quot; /> <item subscription=&quot;both&quot; jid=&quot;jaiku@jaiku.com&quot; > <group>Buddies</group> </item> </query> </iq>
  • 18. Psi2GoogleTalk ( vCard 取得) -- C2S -- -- vCard Action: Resulting Stanza -- -- XEP-0054 6.2 URI Query Types -- <iq type=&quot;get&quot; to=&quot;daibak@gmail.com&quot; id=&quot;aab9a&quot; > <vCard xmlns=&quot;vcard-temp“ version=&quot;2.0“ prodid=&quot;-//HandGen//NONSGML vGen v1.0//EN&quot; /> </iq> <iq from= [email_address] type=&quot;result“ to=daibak@gmail.com/griffin9EB3DE9D id=&quot;aab9a&quot; > <vCard xmlns=&quot;vcard-temp&quot;> <FN>Keiichi daiba</FN> <PHOTO> <TYPE>image/jpeg</TYPE> <BINVAL>...</BINVAL> </PHOTO> </vCard> </iq> バイナリデータをBasa64? 変換して埋め込んである
  • 19. Psi2GoogleTalk (メッセージ送受信) -- BOT にメッセージを送る -- <message type=&quot;chat&quot; to=&quot;en2ja@bot.talk.google.com&quot; id=&quot;aabea&quot; > <body>general</body> <active xmlns=&quot;http://jabber.org/protocol/chatstates&quot;/> </message> <message from=&quot;en2ja@bot.talk.google.com&quot; type=&quot;chat&quot; to=&quot;daibak@gmail.com/griffinEB79CC3A&quot; > <body> 全般 </body> </message>
  • 20. Psi2OpenFire (ルーム作成) -- C2S -- -- チャットルーム作成 -- <presence to=&quot;test@ conference .foo.hoge.co.jp/test&quot; > <priority>0</priority> <x xmlns=&quot;http://jabber.org/protocol/muc&quot;> <history maxchars=&quot;0&quot; /> </x> </presence> -- S2C – -- 成功 -- <presence from=test@conference.foo.hoge.co.jp/test to=“daiba@foo.hoge.co.jp/Psi&quot; > <priority>0</priority> <x xmlns=&quot;http://jabber.org/protocol/muc#user&quot;> <item affiliation=&quot;owner“ role=&quot;moderator“ jid=“daiba@foo.hoge.co.jp/Psi&quot; /> <status code=&quot;201&quot; /> </x> </presence> “ conference “ は OpenFire のデフォルト設定 ルーム名 “ test “ ,ニックネームも “ test “ -- C2S -- <iq type=&quot;set&quot; to=&quot;test@conference.foo.hoge.co.jp&quot; id=&quot;aac1a&quot; > <query xmlns=&quot;http://jabber.org/protocol/muc#owner&quot;> <x xmlns=&quot;jabber:x:data&quot; type=&quot;submit&quot; /> </query> </iq> -- S2C – <message from=test@conference.foo.hoge.co.jp type=&quot;groupchat“ to=“daiba@foo.hoge.co.jp/Psi&quot; > <body> This room is locked from entry until configuration is confirmed. </body> </message> <message from=test@conference.foo.hoge.co.jp type=&quot;groupchat“ to=“daiba@foo.hoge.co.jp/Psi&quot; > <body>This room is now unlocked.</body> </message> 作成した状態ではLOCKされてるので submit してUNLOCK
  • 21. Psi2OpenFire (設定確認) -- C2S -- -- 設定確認 – <iq from=‘daiba@foo.hoge.co.jp/Psi' id='config1' to='test@conference.foo.hoge.co.jp' type='get'> <query xmlns='http://jabber.org/protocol/muc#owner'/> </iq> -- S2C -- -- 確認したデータ -- <iq from=test@conference.foo.hoge.co.jp type=&quot;result“ id=&quot;config1“ to=“daiba@foo.hoge.co.jp/Psi&quot; > <query xmlns=&quot;http://jabber.org/protocol/muc#owner&quot;> <x xmlns=&quot;jabber:x:data&quot; type=&quot;form&quot; > <title>Room configuration</title> <instructions>...</instructions> <field type=&quot;hidden&quot; var=&quot;FORM_TYPE&quot; > <value>http://jabber.org/protocol/muc#roomconfig</value> </field> <field type=&quot;text-single“ label=&quot;Room Name“ var=&quot;muc#roomconfig_roomname&quot; > <value>test</value> </field> ... <field type=&quot;list-single“ label=&quot;Maximum Room Occupants“ var=&quot;muc#roomconfig_maxusers&quot; > <value>30</value> <option label=&quot;10&quot; > <value>10</value> </option> <option label=&quot;20&quot; > <value>20</value> </option> <option label=&quot;30&quot; > <value>30</value> </option> <option label=&quot;40&quot; > <value>40</value> </option> <option label=&quot;50&quot; > <value>50</value> </option> <option label=&quot;None&quot; > <value>0</value> </option> </field> ... </x> </query> </iq> 初期設定で, 参加可能な人数は30 パラメータを何も 指定しないとすべての 設定を返す
  • 22. Psi2OpenFire (設定変更) -- 設定変更 -- -- C2S -- <iq from=‘daiba@foo.hoge.co.jp/Psi' id='create2' to='test@conference.foo.hoge.co.jp' type='set'> <query xmlns='http://jabber.org/protocol/muc#owner'> <x xmlns='jabber:x:data' type='submit'> <field var='muc#roomconfig_maxusers'> <value>0</value> </field> </x> </query> </iq> -- S2C -- <iq from=test@conference.turk.nttr.co.jp type=&quot;result“ id=&quot;create2“ to=“daiba@foo.hoge.co.jp/Psi&quot; /> Psi の XML コンソールを使って手動で XML 送信 < value > 0 < / value > が最大入室無制限