Symbian OS中的Client/Server机制分析
2010-09-06 08:10:00 来源:WEB开发网@return The handle to the server.
*/
inline RServer2 Server() const { return iServer; }
protected:
inline const RMessage2& Message() const;
IMPORT_C CServer2(TInt aPriority, TServerType aType=EUnsharableSessions);
IMPORT_C void DoCancel();
IMPORT_C void RunL();
IMPORT_C TInt RunError(TInt aError);
private:
/**
Creates a server-side session object.
The session represents a communication link between a client and a server, and its creation is initiated by the client through a call to one of the RSessionBase::CreateSession() variants.
A server must provide an implementation, which as a minimum should:
- check that the version of the server is compatible with the client by comparing the client supplied version number against the server's version number; it should leave if there is incompatibility.
- construct and return the server side client session object.
@param aVersion The version information supplied by the client.
@param aMessage Represents the details of the client request that is requesting the creation of the session.
@return A pointer to the newly created server-side session object.
@see User::QueryVersionSupported()
*/
IMPORT_C virtual CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const =0;
...
...
};
有两个API需要我们注意一下:
IMPORT_C void StartL(const TDesC& aName);
SDK 中描述是把指定名称的Server加入到AS中,并且触发一个请求。一般这个函数会在我们自己写的类的ConstructL()中调用。因为 CServer2是从CActive派生的,所以我们可以猜测在StartL中,会触发一个请求,然后调用CActive的方法SetActive来表明 AO启动了请求。
更多精彩
赞助商链接