More Related Content Similar to XMPP仕様簡単解説(20) XMPP仕様簡単解説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 6. セッション TCP TLS SASL Resource Binding ( user @ domain / resource ) クライアント サーバ < session / > < message / >, < presence / > option メッセージの やりとりをする までに必要な 設定 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 属性も理由がない限り必須 10. Psi2OpenFire ( TLS 開設まで) -- C2S— <?xml version="1.0"?> <stream:stream xmlns:stream="http://etherx.jabber.org/streams" version="1.0" xmlns="jabber:client" to="foo.hoge.co.jp" xml:lang="en" xmlns:xml="http://www.w3.org/XML/1998/namespace" > -- S2C -- <?xml version='1.0' encoding='UTF-8'?> <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="foo.hoge.co.jp" id="b9a694d9" xml:lang="en" version="1.0"> -- S2C -- -- TLS による通信要求 -- <stream:features> <starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"/> <mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"> <mechanism>PLAIN</mechanism> <mechanism>CRAM-MD5</mechanism> <mechanism>ANONYMOUS</mechanism> <mechanism>DIGEST-MD5</mechanism> </mechanisms> <compression xmlns="http://jabber.org/features/compress"> <method>zlib</method> </compression> <auth xmlns="http://jabber.org/features/iq-auth"/> <register xmlns="http://jabber.org/features/iq-register"/> </stream:features> -- C2S -- -- TLS による通信開始 -- <starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"/> -- S2C -- -- サーバが TLS 開始を確認 -- <proceed xmlns="urn:ietf:params:xml:ns:xmpp-tls"/> よくみると,サーバは一度に要求 してるが,クライアントはひとつずつ 応えている 11. セッション TCP TLS SASL Resource Binding ( user @ domain / resource ) クライアント サーバ < session / > < message / >, < presence / > option メッセージの やりとりをする までに必要な 設定 12. Psi2OpenFire ( SASL 開設まで) -- C2S -- -- TLS による通信開始 -- <?xml version="1.0"?> <stream:stream xmlns:stream="http://etherx.jabber.org/streams" version="1.0" xmlns="jabber:client" to="foo.hoge.co.jp" xml:lang="en" xmlns:xml="http://www.w3.org/XML/1998/namespace" > -- S2C -- -- サーバからの応答開始 -- <?xml version='1.0' encoding='UTF-8'?> <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="foo.hoge.co.jp" id="b9a694d9" xml:lang="en" version="1.0"> -- S2C -- -- SASL 要求 -- <stream:features> <mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"> <mechanism>PLAIN</mechanism> <mechanism>CRAM-MD5</mechanism> <mechanism>ANONYMOUS</mechanism> <mechanism>DIGEST-MD5</mechanism> </mechanisms> <compression xmlns="http://jabber.org/features/compress"> <method>zlib</method> </compression> <auth xmlns="http://jabber.org/features/iq-auth"/> <register xmlns="http://jabber.org/features/iq-register"/> </stream:features> -- C2S -- <auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl“ mechanism="DIGEST-MD5" /> -- S2C -- <challenge xmlns="urn:ietf:params:xml:ns:xmpp-sasl">...</challenge> -- C2S -- -- クライアントがレスポンスを送信 -- <response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">...</response> -- S2C -- -- サーバが認証成功宣言 -- <success xmlns="urn:ietf:params:xml:ns:xmpp-sasl">...</success> GTalk は SSL を使ってるので TLS での通信要求はでない 13. セッション TCP TLS SASL Resource Binding ( user @ domain / resource ) クライアント サーバ < session / > < message / >, < presence / > option メッセージの やりとりをする までに必要な 設定 14. Psi2OpenFire (圧縮モード設定まで) -- C2S -- -- SASL ベースで再度アクセス -- <?xml version="1.0"?> <stream:stream xmlns:stream="http://etherx.jabber.org/streams" version="1.0" xmlns="jabber:client" to="foo.hoge.co.jp" xml:lang="en" xmlns:xml="http://www.w3.org/XML/1998/namespace" > -- S2C -- -- サーバ応答 -- <?xml version='1.0' encoding='UTF-8'?> <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="foo.hoge.co.jp" id="b9a694d9" xml:lang="en" version="1.0"> -- S2C -- -- traffic を圧縮するかどうかを確認してる -- -- Psi で "Compress traffic" にチェックしてないので無反応 -- <stream:features> <compression xmlns="http://jabber.org/features/compress"> <method>zlib</method> </compression> <bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"/> <session xmlns="urn:ietf:params:xml:ns:xmpp-session"/> </stream:features> 15. Psi2OpenFire ( Roster 取得まで) -- C2S -- -- Client asks server to bind a resource: -- -- RFC3920 7. Resource Binding -- <iq type="set" id="bind_1" > <bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"> <resource>Psi</resource> </bind> </iq> -- S2C -- -- Server informs client of successful resource binding: -- -- RFC3920 7. Resource Binding -- <iq xmlns="jabber:client" type="result" id="bind_1" to="foo.hoge.co.jp/b9a694d9" > <bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"> <jid> daiba@foo.hoge.co.jp/Psi </jid> </bind> </iq> -- C2S -- -- Client requests session with server: -- -- RFC3921 3. Session Establishment -- <iq type="set" id="aab5a" > <session xmlns="urn:ietf:params:xml:ns:xmpp-session"/> </iq> -- S2C -- --Server informs client that session has been created -- -- この段階で "active resource" としてサーバに登録された -- <iq type="result" id="aab5a" to="daiba@foo.hoge.co.jp/Psi" > <session xmlns="urn:ietf:params:xml:ns:xmpp-session"/> </iq> -- C2S -- -- Client requests current roster from server: -- -- 7.3. Retrieving One's Roster on Login -- <iq type="get" id="aab6a" > <query xmlns="jabber:iq:roster"/> </iq> -- S2C -- -- Client receives roster from server: -- <iq type="result" id="aab6a" to="daiba@foo.hoge.co.jp/Psi" > <query xmlns="jabber:iq:roster"/> </iq> resource ってのは, [email_address] / Psi の “ Psi “ の部分 16. Psi2OpenFire ( Priority 設定まで) -- C2S -- -- Presence priority: -- -- RFC3921 5.4. Specifying Presence Priority -- <presence> <priority>5</priority> <c xmlns="http://jabber.org/protocol/caps" node="http://psi-im.org/caps" ver="0.11-dev-rev8" ext="cs ep-notify html" /> </presence> 17. Psi2GoogleTalk ( Roster 取得) -- C2S -- -- Client requests current roster from server: -- -- 7.3. Retrieving One's Roster on Login -- <iq type="get" id="aab6a" > <query xmlns="jabber:iq:roster"/> </iq> -- S2C -- -- Client receives roster from server: -- <iq type="result" to="daibak@gmail.com/griffin9EB3DE9D" id="aab6a" > <query xmlns="jabber:iq:roster"> <item subscription=“both” name=“ 誰か " jid=“noname@gmail.com" /> <item subscription="both" jid="twitter@twitter.com" /> <item subscription="both" jid="jaiku@jaiku.com" > <group>Buddies</group> </item> </query> </iq> 18. Psi2GoogleTalk ( vCard 取得) -- C2S -- -- vCard Action: Resulting Stanza -- -- XEP-0054 6.2 URI Query Types -- <iq type="get" to="daibak@gmail.com" id="aab9a" > <vCard xmlns="vcard-temp“ version="2.0“ prodid="-//HandGen//NONSGML vGen v1.0//EN" /> </iq> <iq from= [email_address] type="result“ to=daibak@gmail.com/griffin9EB3DE9D id="aab9a" > <vCard xmlns="vcard-temp"> <FN>Keiichi daiba</FN> <PHOTO> <TYPE>image/jpeg</TYPE> <BINVAL>...</BINVAL> </PHOTO> </vCard> </iq> バイナリデータをBasa64? 変換して埋め込んである 19. Psi2GoogleTalk (メッセージ送受信) -- BOT にメッセージを送る -- <message type="chat" to="en2ja@bot.talk.google.com" id="aabea" > <body>general</body> <active xmlns="http://jabber.org/protocol/chatstates"/> </message> <message from="en2ja@bot.talk.google.com" type="chat" to="daibak@gmail.com/griffinEB79CC3A" > <body> 全般 </body> </message> 20. Psi2OpenFire (ルーム作成) -- C2S -- -- チャットルーム作成 -- <presence to="test@ conference .foo.hoge.co.jp/test" > <priority>0</priority> <x xmlns="http://jabber.org/protocol/muc"> <history maxchars="0" /> </x> </presence> -- S2C – -- 成功 -- <presence from=test@conference.foo.hoge.co.jp/test to=“daiba@foo.hoge.co.jp/Psi" > <priority>0</priority> <x xmlns="http://jabber.org/protocol/muc#user"> <item affiliation="owner“ role="moderator“ jid=“daiba@foo.hoge.co.jp/Psi" /> <status code="201" /> </x> </presence> “ conference “ は OpenFire のデフォルト設定 ルーム名 “ test “ ,ニックネームも “ test “ -- C2S -- <iq type="set" to="test@conference.foo.hoge.co.jp" id="aac1a" > <query xmlns="http://jabber.org/protocol/muc#owner"> <x xmlns="jabber:x:data" type="submit" /> </query> </iq> -- S2C – <message from=test@conference.foo.hoge.co.jp type="groupchat“ to=“daiba@foo.hoge.co.jp/Psi" > <body> This room is locked from entry until configuration is confirmed. </body> </message> <message from=test@conference.foo.hoge.co.jp type="groupchat“ to=“daiba@foo.hoge.co.jp/Psi" > <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="result“ id="config1“ to=“daiba@foo.hoge.co.jp/Psi" > <query xmlns="http://jabber.org/protocol/muc#owner"> <x xmlns="jabber:x:data" type="form" > <title>Room configuration</title> <instructions>...</instructions> <field type="hidden" var="FORM_TYPE" > <value>http://jabber.org/protocol/muc#roomconfig</value> </field> <field type="text-single“ label="Room Name“ var="muc#roomconfig_roomname" > <value>test</value> </field> ... <field type="list-single“ label="Maximum Room Occupants“ var="muc#roomconfig_maxusers" > <value>30</value> <option label="10" > <value>10</value> </option> <option label="20" > <value>20</value> </option> <option label="30" > <value>30</value> </option> <option label="40" > <value>40</value> </option> <option label="50" > <value>50</value> </option> <option label="None" > <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="result“ id="create2“ to=“daiba@foo.hoge.co.jp/Psi" /> Psi の XML コンソールを使って手動で XML 送信 < value > 0 < / value > が最大入室無制限