bool Dispatch(
string methodName,
);
这个methodName在托管代码里,他将收到这个分配的消息,并处理它。
返回值:如果成功的转发指定的方法将返回true.否则返回false.
备注:如果你的应用程序用script-only标记,那么你用Dispatch的话编译将失败。
示例:下面的代码显示了Dispatch函数在application manifest内部的具体用法。和它自身的事件句柄方法(event handler methods)的样例。
<?xml version="1.0" ?>
<lc:applicationManifest
appUri="http://www.adatum.com/myApplicationLocation"
xmlns:lc="http://schemas.microsoft.com/lc/2003/05">
<lc:splScript><![CDATA[
if (sipRequest) {
if (sipRequest.Method == StandardMethod.Invite) {
Dispatch("OnInvite");
}
else if (sipRequest.Method == StandardMethod.Message) {
Dispatch("OnMessage");
}
}
]]></lc:splScript>
</lc:applicationManifest>
public void OnInvite (object sender, RequestReceivedEventArgs requestArgs) {
// INVITE request processing goes here.
}public void OnMessage (object sender, RequestReceivedEventArgs requestArgs) {
// MESSAGE request processing goes here.
}
2、事务(Transaction)
当两个用户代理交换SIP消息的时候,发送请求的用户代理(UA)就是用户代理客户端(UAC,User Agent Client)而返回应答的用户代理则是用户代理服务器(UAS,User Agent Server)。SIP请求连同一个它所触发的应答被叫做一个SIP事务。
二、Microsoft.Rtc.Sip Namespace
The ApplicationManifest class defines the application manifest for a SIP application.
The BranchCollection class represents an unordered collection of client transactions (branches) associated with a server transaction. Each client transaction is represented as a ClientTransaction object, and can be obtained through the IEnumerator interface returned by the GetEnumerator() method.
注:关于GetEnumerator()方法,BranchCollection.GetEnumerator;关于IEnumerator接口,是所有枚举的基接口。
BranchCollection对象是通过ServerTransaction.Branches获得的。它包含这个服务器端事务的全部客户端事务。
这个类实现IEnumerable接口。
The ClientTransaction class defines a SIP client transaction object located on a SIP proxy.
A ClientTransaction object is created by calling CreateBranch on a ServerTransaction object. For forking proxy behaviors, ServerTransaction.CreateBranch can be called multiple times; however, a ClientTransaction object itself can service only one request. To send the request, call ClientTransaction.SendRequest.
To handle the responses for the request sent by a specific client transaction, you must register for the ClientTransaction.ResponseReceived event. This event will return a ResponseReceivedEventArgs object whenever it is raised, and contains the response as a Response object.
Currently, the UAC client transaction case is not supported, where the server originates a client transaction. Only proxy behaviors are available for this class.
The ClientTransaction class is derived from the Microsoft.Rtc.Sip.Transaction class.
The Response class defines a SIP response sent from a server transaction to a client transaction.
To generate a response message for a request, call CreateResponse on the associated Request object. P5opulate the Response message with the proper status class and reason phrase, and then pass it to ServerTransaction.SendResponse, using the ServerTransaction object for the initial request.
There are two methods for receiving a response:
The Response class is derived from the Microsoft.Rtc.Sip.Message class.
The Request class defines a SIP request sent from a client transaction to a server transaction.
Client transactions are represented as a ClientTransaction object, and server transactions are represented as a ServerTransaction object. A request is sent by calling the ClientTransaction.SendRequest method. Any transaction may have only one associated request.
Requests are proxied by calling ServerTransaction.CreateBranch and creating an associated ClientTransaction object for the proxied request. To fork a request, call ServerTransaction.CreateBranch once for each fork, and then call ClientTransaction.SendRequest on each element in the BranchCollection found at ServerTransaction.Branches.
To generate a response message for a request, call CreateResponse on the associated Request object. Populate the Response message with the proper status class and reason phrase, and then pass it to ServerTransaction.SendResponse, using the ServerTransaction object for the initial request.
When a response is returned for a specific request, a ResponseReceived event is raised on the ClientTransaction object that sent the request, and a ResponseReceivedEventArgs object is supplied to the method provided to the ResponseReceivedEventHandler delegate.
The Request class is derived from the Microsoft.Rtc.Sip.Message class.
The ServerAgent class implements a Live Communications server agent.
Applications use ServerAgent objects to interact with the Live Communications Server. Each object of this class represents a logical SIP application to the server. Most applications will create only one such object, but in special cases, it may be necessary to create multiple server agent objects (such as for logging all incoming and all outgoing messages).
Before a ServerAgent object is instantiated, an application manifest should be created to describe the application to the server and provide the message filtering service.
This class implemented the IDisposable interface.
The ServerAgent class is derived from the System.Object class.
The Transaction class provides the abstract base class for the ServerTransaction and ClientTransaction classes, and represents a generic SIP transaction.
This class implements the IDisposable interface.
The Transaction class is derived from the System.Object class.
The ServerTransaction class defines a SIP server transaction object located on a SIP proxy or user agent server (UAS).
A ServerTransaction instance is generated as the RequestReceivedEventArgs.ServerTransaction property, available on the RequestReceivedEventArgs object dispatched to a specific method by the MSPL script filter. (See the Dispatch MSPL built-in function for more information.) There are no public constructors for this class.
The request being serviced by this server transaction can be forwarded by calling ServerTransaction.CreateBranch, which will create an associated ClientTransaction. To fork a message, CreateBranch can be called for each fork. The collection of branches for this server transaction can be obtained as a BranchCollection object by referencing the ServerTransaction.Branches property. Requests are sent by calling ClientTransaction.SendRequest on each branch.
To send a response for the request the server transaction was created to service, call ServerTransaction.SendResponse with the Response object created by calling Request.CreateResponse on the Request object available in the RequestReceivedEventArgs.Request property.
The ServerTransaction class is derived from the Microsoft.Rtc.Sip.Transaction class.
The Header class defines a SIP header.
The Header class is derived from the System.Object class.
The following code sample sends a redirection response with the new endpoint address in the "Contact" header. Requests are dispatched to this method from the MSPL script in the application manifest using the Dispatch MSPL function.
public void OnRequest(object sender, RequestReceivedEventArgs rreArgs)
{
// Send a generic response to the sender indicating redirection (302). Response response = rreArgs.Request.CreateResponse(302);
response.ReasonPhrase = "Redirected by Live Communications Server";
// Add the "Contact" header indicating the new redirection address of the SIP user.
// In this example, the localhost is supplied; in a real application, the second
// parameter of the Header constructor would be the redirection address of the user.
Header h = new Header("Contact", "sip:127.0.0.1:5060;transport=tcp");
response.AllHeaders.Add(h);
// Send the response.
rreArgs.ServerTransaction.SendResponse(response);
}
The following code sample iterates through a HeaderCollection and writes the header type along with its associated value. In this case, the HeaderCollection is the AllHeaders property set on an incoming Request.
The Message class defines the abstract base class for SIP message classes. It contains a parsed SIP message, separated into its component headers and content.
The Request and Response classes inherit from this class. Objects of these types are generated by transactions (represented as a Transaction type or derived type, such as ClientTransaction and ServerTransaction) between two proxies.
Message headers are represented as Header objects. The collection of all headers on a message is found in the Message.AllHeaders property, which contains a HeaderCollection object. This HeaderCollection object contains all of the headers defined on the message. The content of a message is accessible through the Message.Content property.
This class implements the ICloneable interface.
The Message class is derived from the System.Object class.
The CompilerErrorException class defines the exception that is thrown when an application manifest compiler encounters an error.
The CompilerErrorException class is derived from the System.ApplicationException class.
The ConnectionDroppedEventArgs class defines the object returned by the ServerAgent.ConnectionDropped event.
The ConnectionDroppedEventArgs class is derived from the System.EventArgs class.
The RequestReceivedEventArgs class defines information to an application regarding the arrival of a SIP request.
When a request has been successfully dispatched by the MSPL message filter (see the Dispatch built-in function), an event containing a RequestReceivedEventArgs object will be dispatched to the specified method (whose signature must match the RequestReceivedEventHandler delegate). RequestReceivedEventArgs contains the request as the RequestReceivedEventArgs.Request property.
An instance of ServerTransaction is created as a property of RequestReceivedEventArgs. This property represents the new server transaction for the request. To forward this request, call ServerTransaction.CreateBranch to create a ClientTransaction and call ClientTransaction.SendRequest, passing the Request object in the RequestReceivedEventArgs.Request property.
The RequestReceivedEventArgs class is derived from the System.EventArgs class.
参考文档《Microsoft Office Live Communications Server 2005》
自由广告区 |
分类导航 |
邮件新闻资讯: IT业界 | 邮件服务器 | 邮件趣闻 | 移动电邮 电子邮箱 | 反垃圾邮件|邮件客户端|网络安全 行业数据 | 邮件人物 | 网站公告 | 行业法规 网络技术: 邮件原理 | 网络协议 | 网络管理 | 传输介质 线路接入 | 路由接口 | 邮件存储 | 华为3Com CISCO技术 | 网络与服务器硬件 操作系统: Windows 9X | Linux&Uinx | Windows NT Windows Vista | FreeBSD | 其它操作系统 邮件服务器: 程序与开发 | Exchange | Qmail | Postfix Sendmail | MDaemon | Domino | Foxmail KerioMail | JavaMail | Winwebmail |James Merak&VisNetic | CMailServer | WinMail 金笛邮件系统 | 其它 | 反垃圾邮件: 综述| 客户端反垃圾邮件|服务器端反垃圾邮件 邮件客户端软件: Outlook | Foxmail | DreamMail| KooMail The bat | 雷鸟 | Eudora |Becky! |Pegasus IncrediMail |其它 电子邮箱: 个人邮箱 | 企业邮箱 |Gmail 移动电子邮件:服务器 | 客户端 | 技术前沿 邮件网络安全: 软件漏洞 | 安全知识 | 病毒公告 |防火墙 攻防技术 | 病毒查杀| ISA | 数字签名 邮件营销: Email营销 | 网络营销 | 营销技巧 |营销案例 邮件人才:招聘 | 职场 | 培训 | 指南 | 职场 解决方案: 邮件系统|反垃圾邮件 |安全 |移动电邮 |招标 产品评测: 邮件系统 |反垃圾邮件 |邮箱 |安全 |客户端 |