CPIM 消息格式

CPIM 消息格式

SIP 協議詳解 中提到過一種Sip body消息體格式Message/CPIM,這一節來了解一下CPIM消息格式。
CPIM (Common Presence and Instant Messaging) 是一種IM通信中的會話描述格式,其對應的傳輸協議可以是Sip(Session Initiation Protocol)。
CPIM具體的消息格式由 RFC3862 定義。

一、CPIM 消息舉例

首先拿一個CPIM消息進行舉例:

m: Content-type: Message/CPIM
s:
h: From: MR SANDERS <im:[email protected]>
h: To: Depressed Donkey <im:[email protected]>
h: DateTime: 2000-12-13T13:40:00-08:00
h: Subject: the weather will be fine today
h: Subject:;lang=fr beau temps prevu pour aujourd'hui
h: NS: MyFeatures <mid:[email protected]>
h: Require: MyFeatures.VitalMessageOption
h: MyFeatures.VitalMessageOption: Confirmation-requested
h: MyFeatures.WackyMessageOption: Use-silly-font
s:
e: Content-type: text/xml; charset=utf-8
e: Content-ID: <[email protected]>
e:
e: <body>
e: Here is the text of my message.
e: </body>

標籤“m:”,“s:”,“h:”並不是消息格式的一部分,而是用來區分消息的不同部分,具體含義如下:

  • m: 整個消息的MIME消息頭 Message/CPIM
  • s: 空格分隔行
  • h: 消息頭
  • e: 包含消息內容在內的封裝好的MIME對象

Message/CPIM由兩部分實體構成:
第一部分爲消息元數據Header,以上案例中的h
第二部分爲消息內容,以上案例中的e
這兩部分內容與按照其Content-type定義的MIME類型封裝,且相互獨立;he之間用用空格行隔開。

二、元數據Header中字段含義說明

Header 解釋 示例
From 消息的發送者或發起者 Indicates the sender or originator of a message. From: MR SANDERS im:[email protected]
To 消息的接收者 Specifies an intended recipient of a message. To: Depressed Donkey im:[email protected]
cc 可以理解成抄送的目標接收者 Indicates a courtesy copy recipient of a message. cc: Winnie the Pooh im:[email protected]
DateTime 消息的發送時間Specifies the date and time a message was sent. DateTime: 2000-12-13T13:40:00-08:00
Subject 消息主題 和 語種描述 Subject:;lang=en Eeyore’s feeling very depressed today
NS 命名空間前綴 Declare a local namespace prefix. NS: MyAlias mid:[email protected]
Require Specify a header or feature that must be implemented by the receiver for correct message processing. Require: MyFeatures.VitalMessageOption MyFeatures.VitalMessageOption: Confirmation-requested

參考:

RFC3862:https://tools.ietf.org/html/rfc3862

Instant Messaging and Presence Protocol:
https://en.wikipedia.org/wiki/Instant_Messaging_and_Presence_Protocol

========== THE END ==========

wx_gzh.jpg

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章