Родитель
b62b13324a
Коммит
4a1c6ce82c
|
@ -17,7 +17,7 @@
|
||||||
* Rights Reserved.
|
* Rights Reserved.
|
||||||
*
|
*
|
||||||
* Contributor(s):
|
* Contributor(s):
|
||||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
* Sergey Lunegov <lvv@sparc.spb.su>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -85,16 +85,19 @@ urpComponentLoader::urpComponentLoader()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_orb->GetORB(&orb);
|
_orb->GetORB(&orb);
|
||||||
bcOID oid;
|
// bcOID oid;
|
||||||
|
bcOID oid = -860880895;
|
||||||
transport = new urpConnector();
|
transport = new urpConnector();
|
||||||
PRStatus status = transport->Open("socket,host=indra,port=20009");
|
PRStatus status = transport->Open("socket,host=localhost,port=20009");
|
||||||
if(status != PR_SUCCESS) {
|
if(status != PR_SUCCESS) {
|
||||||
printf("Error during opening connection\n");
|
printf("Error during opening connection\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
man = new urpManager(PR_TRUE, nsnull, transport->GetConnection());
|
urpConnection* conn = transport->GetConnection();
|
||||||
stub = new urpStub(man);
|
man = new urpManager(PR_TRUE, nsnull, conn);
|
||||||
oid = orb->RegisterStub(stub);
|
stub = new urpStub(man, conn);
|
||||||
|
// oid = orb->RegisterStub(stub);
|
||||||
|
orb->RegisterStubWithOID(stub, &oid);
|
||||||
xpcomStubsAndProxies->GetProxy(oid, NS_GET_IID(nsIComponentManager), orb, &proxy);
|
xpcomStubsAndProxies->GetProxy(oid, NS_GET_IID(nsIComponentManager), orb, &proxy);
|
||||||
compM = (nsIComponentManager*)proxy;
|
compM = (nsIComponentManager*)proxy;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "nsIInterfaceInfoManager.h"
|
#include "nsIInterfaceInfoManager.h"
|
||||||
#include "nsIComponentManager.h"
|
#include "nsIComponentManager.h"
|
||||||
#include "urpITest.h"
|
#include "urpITest.h"
|
||||||
|
#include "urpTestImpl.h"
|
||||||
|
|
||||||
static char * className = "initImpl";
|
static char * className = "initImpl";
|
||||||
|
|
||||||
|
@ -103,6 +104,10 @@ initImpl::initImpl() {
|
||||||
for (unsigned int i = 0; i < 4; i++) {
|
for (unsigned int i = 0; i < 4; i++) {
|
||||||
printf("valueArray[%d]=%s\n",i,(*valueArray2)[i]);
|
printf("valueArray[%d]=%s\n",i,(*valueArray2)[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
urpITest *object = new urpTestImpl();
|
||||||
|
object->AddRef();
|
||||||
|
serverComponent->Test6(object);
|
||||||
{
|
{
|
||||||
urpITest *p1;
|
urpITest *p1;
|
||||||
serverComponent->Test7(&p1);
|
serverComponent->Test7(&p1);
|
||||||
|
|
|
@ -87,9 +87,12 @@ nsIInterfaceInfo *interfaceInfo;
|
||||||
printf("Error during opening connection\n");
|
printf("Error during opening connection\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
urpManager* man = new urpManager(PR_TRUE, nsnull, transport->GetConnection());
|
urpConnection* conn = transport->GetConnection();
|
||||||
stub = new urpStub(man);
|
urpManager* man = new urpManager(PR_TRUE, nsnull, conn);
|
||||||
bcOID oid = orb->RegisterStub(stub);
|
stub = new urpStub(man, conn);
|
||||||
|
bcOID oid = 1221591041;
|
||||||
|
// bcOID oid = orb->RegisterStub(stub);
|
||||||
|
orb->RegisterStubWithOID(stub, &oid);
|
||||||
printf("---urpTestImpl oid=%ld iid=%s\n",oid, NS_GET_IID(urpITest).ToString());
|
printf("---urpTestImpl oid=%ld iid=%s\n",oid, NS_GET_IID(urpITest).ToString());
|
||||||
r = xpcomStubsAndProxies->GetProxy(oid,NS_GET_IID(urpITest),orb,(nsISupports**)&proxy);
|
r = xpcomStubsAndProxies->GetProxy(oid,NS_GET_IID(urpITest),orb,(nsISupports**)&proxy);
|
||||||
if (NS_FAILED(r)) {
|
if (NS_FAILED(r)) {
|
||||||
|
@ -148,7 +151,7 @@ nsIInterfaceInfo *interfaceInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************/
|
/*********************************************/
|
||||||
// proxy->Test6(object);
|
proxy->Test6(object);
|
||||||
/*********************************************/
|
/*********************************************/
|
||||||
{
|
{
|
||||||
urpITest *p1;
|
urpITest *p1;
|
||||||
|
@ -167,6 +170,7 @@ nsIInterfaceInfo *interfaceInfo;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// trans->Close();
|
delete conn;
|
||||||
|
transport->Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
static NS_DEFINE_CID(kXPCOMStubsAndProxies,BC_XPCOMSTUBSANDPROXIES_CID);
|
static NS_DEFINE_CID(kXPCOMStubsAndProxies,BC_XPCOMSTUBSANDPROXIES_CID);
|
||||||
static NS_DEFINE_CID(kORBCIID,BC_ORBCOMPONENT_CID);
|
static NS_DEFINE_CID(kORBCIID,BC_ORBCOMPONENT_CID);
|
||||||
|
static NS_DEFINE_CID(compManag, NS_COMPONENTMANAGER_CID);
|
||||||
|
|
||||||
struct localThreadArg {
|
struct localThreadArg {
|
||||||
urpManager *mgr;
|
urpManager *mgr;
|
||||||
|
@ -50,6 +51,8 @@ int main( int argc, char *argv[] ) {
|
||||||
nsresult rv = NS_InitXPCOM(NULL, NULL);
|
nsresult rv = NS_InitXPCOM(NULL, NULL);
|
||||||
NS_ASSERTION( NS_SUCCEEDED(rv), "NS_InitXPCOM failed" );
|
NS_ASSERTION( NS_SUCCEEDED(rv), "NS_InitXPCOM failed" );
|
||||||
|
|
||||||
|
(void) nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, nsnull);
|
||||||
|
|
||||||
NS_WITH_SERVICE(bcIORBComponent, _orb, kORBCIID, &rv);
|
NS_WITH_SERVICE(bcIORBComponent, _orb, kORBCIID, &rv);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
printf("NS_WITH_SERVICE(bcXPC in Marshal failed\n");
|
printf("NS_WITH_SERVICE(bcXPC in Marshal failed\n");
|
||||||
|
@ -64,17 +67,19 @@ printf("NS_WITH_SERVICE(bcXPC in Marshal failed\n");
|
||||||
bcIORB *orb;
|
bcIORB *orb;
|
||||||
_orb->GetORB(&orb);
|
_orb->GetORB(&orb);
|
||||||
bcIStub *stub = nsnull;
|
bcIStub *stub = nsnull;
|
||||||
urpITest *object = new urpTestImpl();
|
NS_WITH_SERVICE(nsIComponentManager, mComp, compManag, &rv);
|
||||||
object->AddRef();
|
if (NS_FAILED(rv)) {
|
||||||
|
printf("compManager failed\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
urpITest *proxy = nsnull;
|
urpITest *proxy = nsnull;
|
||||||
xpcomStubsAndProxies->GetStub((nsISupports*)object, &stub);
|
xpcomStubsAndProxies->GetStub((nsISupports*)mComp, &stub);
|
||||||
bcOID oid = orb->RegisterStub(stub);
|
bcOID oid = orb->RegisterStub(stub);
|
||||||
|
|
||||||
urpTransport* trans = new urpAcceptor();
|
urpTransport* trans = new urpAcceptor();
|
||||||
PRStatus status = trans->Open(connectString);
|
PRStatus status = trans->Open(connectString);
|
||||||
if(status == PR_SUCCESS) printf("succes %ld\n",oid);
|
if(status == PR_SUCCESS) printf("succes %ld\n",oid);
|
||||||
else printf("failed\n");
|
else printf("failed\n");
|
||||||
object->AddRef();
|
|
||||||
urpManager* mngr = new urpManager(PR_FALSE, orb, nsnull);
|
urpManager* mngr = new urpManager(PR_FALSE, orb, nsnull);
|
||||||
rv = NS_OK;
|
rv = NS_OK;
|
||||||
while(NS_SUCCEEDED(rv)) {
|
while(NS_SUCCEEDED(rv)) {
|
||||||
|
|
|
@ -69,6 +69,29 @@ struct localThreadArg {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct sendThreadArg {
|
||||||
|
urpManager* man;
|
||||||
|
char header;
|
||||||
|
urpPacket* message;
|
||||||
|
bcIID iid;
|
||||||
|
bcOID oid;
|
||||||
|
bcTID tid;
|
||||||
|
PRUint16 methodId;
|
||||||
|
urpConnection* connection;
|
||||||
|
sendThreadArg(urpManager* m, char header, urpPacket* message, bcIID iid,
|
||||||
|
bcOID oid, bcTID tid, PRUint16 methodId,
|
||||||
|
urpConnection* conn) {
|
||||||
|
this->man = m;
|
||||||
|
this->header = header;
|
||||||
|
this->message = message;
|
||||||
|
this->iid = iid;
|
||||||
|
this->oid = oid;
|
||||||
|
this->tid = tid;
|
||||||
|
this->methodId = methodId;
|
||||||
|
this->connection = conn;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
struct monitCall {
|
struct monitCall {
|
||||||
PRMonitor *mon;
|
PRMonitor *mon;
|
||||||
bcICall* call;
|
bcICall* call;
|
||||||
|
@ -86,12 +109,23 @@ void thread_start( void *arg )
|
||||||
nsresult rv = manager->ReadMessage( connection, ic );
|
nsresult rv = manager->ReadMessage( connection, ic );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void send_thread_start (void * arg) {
|
||||||
|
urpManager *manager = ((sendThreadArg *)arg)->man;
|
||||||
|
char header = ((sendThreadArg *)arg)->header;
|
||||||
|
urpPacket* mes = ((sendThreadArg *)arg)->message;
|
||||||
|
bcIID iid = ((sendThreadArg *)arg)->iid;
|
||||||
|
bcOID oid = ((sendThreadArg *)arg)->oid;
|
||||||
|
bcTID tid = ((sendThreadArg *)arg)->tid;
|
||||||
|
PRUint16 methodId = ((sendThreadArg *)arg)->methodId;
|
||||||
|
urpConnection* conn = ((sendThreadArg *)arg)->connection;
|
||||||
|
nsresult rv = manager->ReadLongRequest(header, mes, iid, oid,
|
||||||
|
tid, methodId, conn);
|
||||||
|
}
|
||||||
|
|
||||||
urpManager::urpManager(PRBool IsClient, bcIORB *orb, urpConnection* conn) {
|
urpManager::urpManager(PRBool IsClient, bcIORB *orb, urpConnection* conn) {
|
||||||
broker = orb;
|
broker = orb;
|
||||||
monitTable = new nsHashtable(20);
|
monitTable = new nsHashtable(20);
|
||||||
if(IsClient) {
|
if(IsClient) {
|
||||||
connTable = nsnull;
|
|
||||||
connection = conn;
|
|
||||||
localThreadArg *arg = new localThreadArg( this, conn, PR_TRUE );
|
localThreadArg *arg = new localThreadArg( this, conn, PR_TRUE );
|
||||||
PRThread *thr = PR_CreateThread( PR_USER_THREAD,
|
PRThread *thr = PR_CreateThread( PR_USER_THREAD,
|
||||||
thread_start,
|
thread_start,
|
||||||
|
@ -104,16 +138,13 @@ urpManager::urpManager(PRBool IsClient, bcIORB *orb, urpConnection* conn) {
|
||||||
printf("Error couldn't run listener\n");
|
printf("Error couldn't run listener\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
connection = nsnull;
|
|
||||||
connTable = new nsHashtable(20);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
urpManager::~urpManager() {
|
urpManager::~urpManager() {
|
||||||
if(connTable)
|
if(monitTable)
|
||||||
delete connTable;
|
delete monitTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -122,7 +153,8 @@ void urpManager::SendUrpRequest(bcOID oid, bcIID iid,
|
||||||
PRUint16 methodIndex,
|
PRUint16 methodIndex,
|
||||||
nsIInterfaceInfo* interfaceInfo,
|
nsIInterfaceInfo* interfaceInfo,
|
||||||
bcICall *call,
|
bcICall *call,
|
||||||
PRUint32 paramCount, const nsXPTMethodInfo* info) {
|
PRUint32 paramCount, const nsXPTMethodInfo* info,
|
||||||
|
urpConnection* connection) {
|
||||||
printf("this is method sendUrpRequest and mid is %x\n",methodIndex);
|
printf("this is method sendUrpRequest and mid is %x\n",methodIndex);
|
||||||
long size = 0;
|
long size = 0;
|
||||||
long messagesCount = 0;
|
long messagesCount = 0;
|
||||||
|
@ -169,18 +201,12 @@ void urpManager::SendUrpRequest(bcOID oid, bcIID iid,
|
||||||
mt->WriteType(iid, message);
|
mt->WriteType(iid, message);
|
||||||
mt->WriteOid(oid, message);
|
mt->WriteOid(oid, message);
|
||||||
bcTID thrID = (bcTID)PR_GetCurrentThread();
|
bcTID thrID = (bcTID)PR_GetCurrentThread();
|
||||||
printf("OID is written %ld\n", thrID);
|
printf("OID is written %ld\n", oid);
|
||||||
mt->WriteThreadID(thrID, message);
|
mt->WriteThreadID(thrID, message);
|
||||||
broker = call->GetORB();
|
broker = call->GetORB();
|
||||||
mt->WriteParams(call, paramCount, info, interfaceInfo, message, methodIndex);
|
mt->WriteParams(call, paramCount, info, interfaceInfo, message, methodIndex);
|
||||||
delete mt;
|
delete mt;
|
||||||
if(connTable) {
|
connection->Write(message);
|
||||||
bcTID thrID = (bcTID)PR_GetCurrentThread();
|
|
||||||
threadHashKey thrHK(thrID);
|
|
||||||
urpConnection* con = connTable->Get(&thrHK);
|
|
||||||
con->Write(message);
|
|
||||||
} else
|
|
||||||
connection->Write(message);
|
|
||||||
delete message;
|
delete message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,11 +218,12 @@ nsresult
|
||||||
urpManager::ReadReply(urpPacket* message, char header,
|
urpManager::ReadReply(urpPacket* message, char header,
|
||||||
bcICall* call, PRUint32 paramCount,
|
bcICall* call, PRUint32 paramCount,
|
||||||
const nsXPTMethodInfo *info,
|
const nsXPTMethodInfo *info,
|
||||||
nsIInterfaceInfo *interfaceInfo, PRUint16 methodIndex) {
|
nsIInterfaceInfo *interfaceInfo, PRUint16 methodIndex,
|
||||||
|
urpConnection* conn) {
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
printf("this is method readReply\n");
|
printf("this is method readReply\n");
|
||||||
urpMarshalToolkit* mt = new urpMarshalToolkit(PR_TRUE);
|
urpMarshalToolkit* mt = new urpMarshalToolkit(PR_TRUE);
|
||||||
rv = mt->ReadParams(paramCount, info, message, interfaceInfo, methodIndex, call, broker, this);
|
rv = mt->ReadParams(paramCount, info, message, interfaceInfo, methodIndex, call, broker, this, conn);
|
||||||
delete mt;
|
delete mt;
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -204,22 +231,45 @@ urpManager::ReadReply(urpPacket* message, char header,
|
||||||
nsresult
|
nsresult
|
||||||
urpManager::ReadMessage(urpConnection* conn, PRBool isClient) {
|
urpManager::ReadMessage(urpConnection* conn, PRBool isClient) {
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
if(!isClient) {
|
PRBool inserted = PR_FALSE;
|
||||||
bcTID thrID = (bcTID)PR_GetCurrentThread();
|
bcTID tid;
|
||||||
threadHashKey thrHK(thrID);
|
|
||||||
connTable->Put(&thrHK, conn);
|
|
||||||
}
|
|
||||||
while(conn->GetStatus() == urpSuccess) {
|
while(conn->GetStatus() == urpSuccess) {
|
||||||
urpPacket* message = conn->Read();
|
urpPacket* message = conn->Read();
|
||||||
char header = message->ReadByte();
|
char header = message->ReadByte();
|
||||||
bcTID tid;
|
|
||||||
if((header & BIG_HEADER) != 0) { // full header?
|
if((header & BIG_HEADER) != 0) { // full header?
|
||||||
if((header & REQUEST) != 0) // a request ?
|
if((header & REQUEST) != 0) { // a request ?
|
||||||
rv = ReadLongRequest(header, message);
|
bcIID iid;
|
||||||
else { // a reply
|
bcOID oid;
|
||||||
|
PRUint16 methodId;
|
||||||
|
if((header & LONGMETHODID) != 0) // usigned short ?
|
||||||
|
methodId = message->ReadShort();
|
||||||
|
else
|
||||||
|
methodId = message->ReadByte();
|
||||||
|
|
||||||
|
urpMarshalToolkit* mt = new urpMarshalToolkit(PR_FALSE);
|
||||||
|
if((header & NEWTYPE) != 0)
|
||||||
|
iid = mt->ReadType(message);
|
||||||
|
|
||||||
|
if((header & NEWOID) != 0) // new oid?
|
||||||
|
oid = mt->ReadOid(message);
|
||||||
|
|
||||||
|
if((header & NEWTID) != 0) // new thread id ?
|
||||||
|
tid = mt->ReadThreadID(message);
|
||||||
|
|
||||||
|
delete mt;
|
||||||
|
|
||||||
|
sendThreadArg *arg = new sendThreadArg( this, header,
|
||||||
|
message, iid, oid, tid, methodId, conn);
|
||||||
|
PRThread *thr = PR_CreateThread( PR_USER_THREAD,
|
||||||
|
send_thread_start,
|
||||||
|
arg,
|
||||||
|
PR_PRIORITY_NORMAL,
|
||||||
|
PR_GLOBAL_THREAD,
|
||||||
|
PR_UNJOINABLE_THREAD,
|
||||||
|
0);
|
||||||
|
} else { // a reply
|
||||||
bcIID iid; bcOID oid; bcMID mid;
|
bcIID iid; bcOID oid; bcMID mid;
|
||||||
|
|
||||||
bcTID tid;
|
|
||||||
urpMarshalToolkit* mt = new urpMarshalToolkit(PR_TRUE);
|
urpMarshalToolkit* mt = new urpMarshalToolkit(PR_TRUE);
|
||||||
if((header & NEWTID) != 0) { // new thread id ?
|
if((header & NEWTID) != 0) { // new thread id ?
|
||||||
printf("new threadID\n");
|
printf("new threadID\n");
|
||||||
|
@ -248,20 +298,17 @@ urpManager::ReadMessage(urpConnection* conn, PRBool isClient) {
|
||||||
nsXPTMethodInfo* info;
|
nsXPTMethodInfo* info;
|
||||||
interfaceInfo->GetMethodInfo(mid, (const nsXPTMethodInfo **)&info);
|
interfaceInfo->GetMethodInfo(mid, (const nsXPTMethodInfo **)&info);
|
||||||
PRUint32 paramCount = info->GetParamCount();
|
PRUint32 paramCount = info->GetParamCount();
|
||||||
ReadReply(message, header, mc->call, paramCount, info, interfaceInfo, mid);
|
ReadReply(message, header, mc->call, paramCount,
|
||||||
|
info, interfaceInfo, mid, conn);
|
||||||
PR_EnterMonitor(mc->mon);
|
PR_EnterMonitor(mc->mon);
|
||||||
PR_Notify(mc->mon);
|
PR_Notify(mc->mon);
|
||||||
PR_ExitMonitor(mc->mon);
|
PR_ExitMonitor(mc->mon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // only a short request header
|
else { // only a short request header
|
||||||
rv = ReadShortRequest(header, message);
|
// rv = ReadShortRequest(header, message);
|
||||||
delete message;
|
break;
|
||||||
}
|
}
|
||||||
if(!isClient) {
|
|
||||||
bcTID thrID = (bcTID)PR_GetCurrentThread();
|
|
||||||
threadHashKey thrHK(thrID);
|
|
||||||
connTable->Remove(&thrHK);
|
|
||||||
}
|
}
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -277,7 +324,8 @@ urpManager::ReadShortRequest(char header, urpPacket* message) {
|
||||||
nsresult
|
nsresult
|
||||||
urpManager::SendReply(bcTID tid, bcICall* call, PRUint32 paramCount,
|
urpManager::SendReply(bcTID tid, bcICall* call, PRUint32 paramCount,
|
||||||
const nsXPTMethodInfo* info,
|
const nsXPTMethodInfo* info,
|
||||||
nsIInterfaceInfo *interfaceInfo, PRUint16 methodIndex) {
|
nsIInterfaceInfo *interfaceInfo, PRUint16 methodIndex,
|
||||||
|
urpConnection* connection) {
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
char header = (char)BIG_HEADER;
|
char header = (char)BIG_HEADER;
|
||||||
header |= NEWTID;
|
header |= NEWTID;
|
||||||
|
@ -289,39 +337,19 @@ urpManager::SendReply(bcTID tid, bcICall* call, PRUint32 paramCount,
|
||||||
methodIndex);
|
methodIndex);
|
||||||
delete mt;
|
delete mt;
|
||||||
if(NS_FAILED(rv)) return rv;
|
if(NS_FAILED(rv)) return rv;
|
||||||
if(connTable) {
|
connection->Write(message);
|
||||||
bcTID thrID = (bcTID)PR_GetCurrentThread();
|
|
||||||
threadHashKey thrHK(thrID);
|
|
||||||
urpConnection* con = (urpConnection*)connTable->Get(&thrHK);
|
|
||||||
con->Write(message);
|
|
||||||
} else
|
|
||||||
connection->Write(message);
|
|
||||||
delete message;
|
delete message;
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
urpManager::ReadLongRequest(char header, urpPacket* message) {
|
urpManager::ReadLongRequest(char header, urpPacket* message,
|
||||||
bcIID iid;
|
bcIID iid, bcOID oid, bcTID tid,
|
||||||
bcOID oid;
|
PRUint16 methodId, urpConnection* conn) {
|
||||||
bcTID tid;
|
|
||||||
PRUint16 methodId;
|
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
if((header & LONGMETHODID) != 0) // usigned short ?
|
|
||||||
methodId = message->ReadShort();
|
|
||||||
else
|
|
||||||
methodId = message->ReadByte();
|
|
||||||
|
|
||||||
urpMarshalToolkit* mt = new urpMarshalToolkit(PR_FALSE);
|
urpMarshalToolkit* mt = new urpMarshalToolkit(PR_FALSE);
|
||||||
if((header & NEWTYPE) != 0)
|
|
||||||
iid = mt->ReadType(message);
|
|
||||||
|
|
||||||
if((header & NEWOID) != 0) // new oid?
|
|
||||||
oid = mt->ReadOid(message);
|
|
||||||
|
|
||||||
if((header & NEWTID) != 0) // new thread id ?
|
|
||||||
tid = mt->ReadThreadID(message);
|
|
||||||
|
|
||||||
printf("method readLongRequest: tid %ld %ld\n",tid,oid);
|
printf("method readLongRequest: tid %ld %ld\n",tid,oid);
|
||||||
char ignore_cache = ((header & IGNORECACHE) != 0); // do not use cache for this request?
|
char ignore_cache = ((header & IGNORECACHE) != 0); // do not use cache for this request?
|
||||||
|
@ -356,11 +384,13 @@ char* name;
|
||||||
interfaceInfo->GetMethodInfo(methodId,(const nsXPTMethodInfo **)&info);
|
interfaceInfo->GetMethodInfo(methodId,(const nsXPTMethodInfo **)&info);
|
||||||
PRUint32 paramCount = info->GetParamCount();
|
PRUint32 paramCount = info->GetParamCount();
|
||||||
bcICall *call = broker->CreateCall(&iid, &oid, methodId);
|
bcICall *call = broker->CreateCall(&iid, &oid, methodId);
|
||||||
mt->ReadParams(paramCount, info, message, interfaceInfo, methodId, call, broker, this);
|
mt->ReadParams(paramCount, info, message, interfaceInfo, methodId, call, broker, this, conn);
|
||||||
delete mt;
|
delete mt;
|
||||||
|
delete message;
|
||||||
//nb return value; excepion handling
|
//nb return value; excepion handling
|
||||||
broker->SendReceive(call);
|
broker->SendReceive(call);
|
||||||
rv = SendReply(tid, call, paramCount, info, interfaceInfo, methodId);
|
rv = SendReply(tid, call, paramCount, info, interfaceInfo,
|
||||||
|
methodId, conn);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,8 @@
|
||||||
|
|
||||||
class urpManager {
|
class urpManager {
|
||||||
|
|
||||||
|
friend void send_thread_start (void * arg);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
urpManager(PRBool IsClient, bcIORB *orb, urpConnection* connection);
|
urpManager(PRBool IsClient, bcIORB *orb, urpConnection* connection);
|
||||||
~urpManager();
|
~urpManager();
|
||||||
|
@ -37,25 +39,31 @@ public:
|
||||||
PRUint16 methodIndex,
|
PRUint16 methodIndex,
|
||||||
nsIInterfaceInfo* interfaceInfo,
|
nsIInterfaceInfo* interfaceInfo,
|
||||||
bcICall *call,
|
bcICall *call,
|
||||||
PRUint32 paramCount, const nsXPTMethodInfo* info);
|
PRUint32 paramCount, const nsXPTMethodInfo* info,
|
||||||
|
urpConnection* conn);
|
||||||
nsresult ReadMessage(urpConnection* conn, PRBool ic);
|
nsresult ReadMessage(urpConnection* conn, PRBool ic);
|
||||||
nsresult SetCall(bcICall* call, PRMonitor *m);
|
nsresult SetCall(bcICall* call, PRMonitor *m);
|
||||||
nsresult RemoveCall();
|
nsresult RemoveCall();
|
||||||
private:
|
private:
|
||||||
nsHashtable* connTable;
|
|
||||||
nsHashtable* monitTable;
|
nsHashtable* monitTable;
|
||||||
bcIORB *broker;
|
bcIORB *broker;
|
||||||
urpConnection* connection;
|
|
||||||
/* for ReadReply */
|
/* for ReadReply */
|
||||||
nsIInterfaceInfo *interfaceInfo;
|
nsIInterfaceInfo *interfaceInfo;
|
||||||
void TransformMethodIDAndIID();
|
void TransformMethodIDAndIID();
|
||||||
nsresult ReadReply(urpPacket* message, char header,
|
nsresult ReadReply(urpPacket* message, char header,
|
||||||
bcICall* call, PRUint32 paramCount, const nsXPTMethodInfo *info, nsIInterfaceInfo *interfaceInfo, PRUint16 methodIndex);
|
bcICall* call, PRUint32 paramCount,
|
||||||
nsresult ReadLongRequest(char header, urpPacket* message);
|
const nsXPTMethodInfo *info,
|
||||||
|
nsIInterfaceInfo *interfaceInfo,
|
||||||
|
PRUint16 methodIndex, urpConnection* conn);
|
||||||
|
nsresult ReadLongRequest(char header, urpPacket* message,
|
||||||
|
bcIID iid, bcOID oid, bcTID tid,
|
||||||
|
PRUint16 methodId, urpConnection* conn);
|
||||||
nsresult ReadShortRequest(char header, urpPacket* message);
|
nsresult ReadShortRequest(char header, urpPacket* message);
|
||||||
nsresult SendReply(bcTID tid, bcICall* call, PRUint32 paramCount,
|
nsresult SendReply(bcTID tid, bcICall* call, PRUint32 paramCount,
|
||||||
const nsXPTMethodInfo* info,
|
const nsXPTMethodInfo* info,
|
||||||
nsIInterfaceInfo *interfaceInfo, PRUint16 methodIndex);
|
nsIInterfaceInfo *interfaceInfo,
|
||||||
|
PRUint16 methodIndex, urpConnection* conn);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -134,17 +134,19 @@ urpMarshalToolkit::WriteElement(bcIUnMarshaler *um, nsXPTParamInfo * param, uint
|
||||||
}
|
}
|
||||||
data = *(char **)data;
|
data = *(char **)data;
|
||||||
size_t length = 0;
|
size_t length = 0;
|
||||||
if (type == nsXPTType::T_WCHAR_STR) {
|
if(data != nsnull) {
|
||||||
length = nsCRT::strlen((const PRUnichar*)data);
|
if (type == nsXPTType::T_WCHAR_STR) {
|
||||||
length *= 2;
|
length = nsCRT::strlen((const PRUnichar*)data);
|
||||||
length +=2;
|
length *= 2;
|
||||||
for (int i = 0; i < length && type == nsXPTType::T_WCHAR_STR; i++) {
|
length +=2;
|
||||||
|
for (int i = 0; i < length && type == nsXPTType::T_WCHAR_STR; i++) {
|
||||||
char c = ((char*)data)[i];
|
char c = ((char*)data)[i];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
length = nsCRT::strlen((const char*)data);
|
length = nsCRT::strlen((const char*)data);
|
||||||
length+=1;
|
length+=1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
message->WriteString((char*)data,length);
|
message->WriteString((char*)data,length);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -216,6 +218,14 @@ urpMarshalToolkit::WriteParams(bcICall *call, PRUint32 paramCount, const nsXPTMe
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
bcIAllocator * allocator = new urpAllocator(nsAllocator::GetGlobalAllocator());
|
bcIAllocator * allocator = new urpAllocator(nsAllocator::GetGlobalAllocator());
|
||||||
bcIUnMarshaler *um = call->GetUnMarshaler();
|
bcIUnMarshaler *um = call->GetUnMarshaler();
|
||||||
|
if(!isClient) {
|
||||||
|
nsresult result;
|
||||||
|
um->ReadSimple(&result, bc_T_U32);
|
||||||
|
if(!NS_SUCCEEDED(result)) {
|
||||||
|
printf("Returned result is error on server side\n");
|
||||||
|
}
|
||||||
|
message->WriteInt(result);
|
||||||
|
}
|
||||||
for(i=0;i<paramCount;i++) {
|
for(i=0;i<paramCount;i++) {
|
||||||
short cache_index;
|
short cache_index;
|
||||||
nsXPTParamInfo param = info->GetParam(i);
|
nsXPTParamInfo param = info->GetParam(i);
|
||||||
|
@ -242,7 +252,8 @@ nsresult
|
||||||
urpMarshalToolkit::ReadElement(nsXPTParamInfo * param, uint8 type,
|
urpMarshalToolkit::ReadElement(nsXPTParamInfo * param, uint8 type,
|
||||||
nsIInterfaceInfo* interfaceInfo, urpPacket* message,
|
nsIInterfaceInfo* interfaceInfo, urpPacket* message,
|
||||||
PRUint16 methodIndex, bcIAllocator* allocator,
|
PRUint16 methodIndex, bcIAllocator* allocator,
|
||||||
bcIMarshaler* m, bcIORB *broker, urpManager* man) {
|
bcIMarshaler* m, bcIORB *broker, urpManager* man,
|
||||||
|
urpConnection* conn) {
|
||||||
void* data = allocator->Alloc(sizeof(void*));
|
void* data = allocator->Alloc(sizeof(void*));
|
||||||
nsresult r = NS_OK;
|
nsresult r = NS_OK;
|
||||||
switch(type) {
|
switch(type) {
|
||||||
|
@ -321,7 +332,7 @@ urpMarshalToolkit::ReadElement(nsXPTParamInfo * param, uint8 type,
|
||||||
nsIID iid = ReadType(message);
|
nsIID iid = ReadType(message);
|
||||||
nsISupports *proxy = NULL;
|
nsISupports *proxy = NULL;
|
||||||
if (oid != 0) {
|
if (oid != 0) {
|
||||||
urpStub* stub = new urpStub(man);
|
urpStub* stub = new urpStub(man, conn);
|
||||||
broker->RegisterStubWithOID(stub, &oid);
|
broker->RegisterStubWithOID(stub, &oid);
|
||||||
}
|
}
|
||||||
m->WriteSimple(&oid, XPTType2bcXPType(type));
|
m->WriteSimple(&oid, XPTType2bcXPType(type));
|
||||||
|
@ -345,7 +356,7 @@ urpMarshalToolkit::ReadElement(nsXPTParamInfo * param, uint8 type,
|
||||||
m->WriteSimple(&arraySize,bc_T_U32);
|
m->WriteSimple(&arraySize,bc_T_U32);
|
||||||
char *current = *(char**)data;
|
char *current = *(char**)data;
|
||||||
for (int i = 0; i < arraySize; i++) {
|
for (int i = 0; i < arraySize; i++) {
|
||||||
ReadElement(param,datumType.TagPart(),interfaceInfo, message, methodIndex, allocator, m, broker, man);
|
ReadElement(param,datumType.TagPart(),interfaceInfo, message, methodIndex, allocator, m, broker, man, conn);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
size_t length = 0;
|
size_t length = 0;
|
||||||
|
@ -368,11 +379,18 @@ urpMarshalToolkit::ReadElement(nsXPTParamInfo * param, uint8 type,
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
urpMarshalToolkit::ReadParams(PRUint32 paramCount, const nsXPTMethodInfo *info, urpPacket* message, nsIInterfaceInfo *interfaceInfo, PRUint16 methodIndex, bcICall* call, bcIORB *orb, urpManager* man) {
|
urpMarshalToolkit::ReadParams(PRUint32 paramCount, const nsXPTMethodInfo *info, urpPacket* message, nsIInterfaceInfo *interfaceInfo, PRUint16 methodIndex, bcICall* call, bcIORB *orb, urpManager* man, urpConnection* conn) {
|
||||||
bcIAllocator * allocator = new urpAllocator(nsAllocator::GetGlobalAllocator());
|
bcIAllocator * allocator = new urpAllocator(nsAllocator::GetGlobalAllocator());
|
||||||
bcIMarshaler* m = call->GetMarshaler();
|
bcIMarshaler* m = call->GetMarshaler();
|
||||||
int i;
|
int i;
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
|
if(isClient) {
|
||||||
|
nsresult result = message->ReadInt();
|
||||||
|
m->WriteSimple(&result, bc_T_U32);
|
||||||
|
if (!NS_SUCCEEDED(result)) {
|
||||||
|
printf("Returned result is error on client side\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
for(i=0;i<paramCount;i++) {
|
for(i=0;i<paramCount;i++) {
|
||||||
short cache_index;
|
short cache_index;
|
||||||
nsXPTParamInfo param = info->GetParam(i);
|
nsXPTParamInfo param = info->GetParam(i);
|
||||||
|
@ -384,7 +402,7 @@ urpMarshalToolkit::ReadParams(PRUint32 paramCount, const nsXPTMethodInfo *info,
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = ReadElement(¶m, param.GetType().TagPart(), interfaceInfo,
|
rv = ReadElement(¶m, param.GetType().TagPart(), interfaceInfo,
|
||||||
message, methodIndex, allocator, m, orb, man);
|
message, methodIndex, allocator, m, orb, man, conn);
|
||||||
if(NS_FAILED(rv)) {
|
if(NS_FAILED(rv)) {
|
||||||
delete allocator;
|
delete allocator;
|
||||||
delete m;
|
delete m;
|
||||||
|
|
|
@ -35,7 +35,7 @@ public:
|
||||||
urpMarshalToolkit(PRBool isClient);
|
urpMarshalToolkit(PRBool isClient);
|
||||||
~urpMarshalToolkit();
|
~urpMarshalToolkit();
|
||||||
|
|
||||||
nsresult ReadParams(PRUint32 paramCount, const nsXPTMethodInfo *info, urpPacket* message, nsIInterfaceInfo *interfaceInfo, PRUint16 methodIndex, bcICall* call, bcIORB *orb, urpManager* man);
|
nsresult ReadParams(PRUint32 paramCount, const nsXPTMethodInfo *info, urpPacket* message, nsIInterfaceInfo *interfaceInfo, PRUint16 methodIndex, bcICall* call, bcIORB *orb, urpManager* man, urpConnection* conn);
|
||||||
nsresult WriteParams(bcICall *call, PRUint32 paramCount, const nsXPTMethodInfo * info, nsIInterfaceInfo* interfaceInfo, urpPacket* message,
|
nsresult WriteParams(bcICall *call, PRUint32 paramCount, const nsXPTMethodInfo * info, nsIInterfaceInfo* interfaceInfo, urpPacket* message,
|
||||||
PRUint16 methodIndex);
|
PRUint16 methodIndex);
|
||||||
void WriteType(bcIID iid, urpPacket* message);
|
void WriteType(bcIID iid, urpPacket* message);
|
||||||
|
@ -55,7 +55,8 @@ private:
|
||||||
nsresult ReadElement(nsXPTParamInfo * param, uint8 type,
|
nsresult ReadElement(nsXPTParamInfo * param, uint8 type,
|
||||||
nsIInterfaceInfo* interfaceInfo, urpPacket* message,
|
nsIInterfaceInfo* interfaceInfo, urpPacket* message,
|
||||||
PRUint16 methodIndex, bcIAllocator * allocator,
|
PRUint16 methodIndex, bcIAllocator * allocator,
|
||||||
bcIMarshaler* m, bcIORB *orb, urpManager* man);
|
bcIMarshaler* m, bcIORB *orb, urpManager* man,
|
||||||
|
urpConnection* conn);
|
||||||
bcXPType XPTType2bcXPType(uint8 type);
|
bcXPType XPTType2bcXPType(uint8 type);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,9 @@
|
||||||
#include "urpManager.h"
|
#include "urpManager.h"
|
||||||
|
|
||||||
|
|
||||||
urpStub::urpStub(urpManager* man) {
|
urpStub::urpStub(urpManager* man, urpConnection* conn) {
|
||||||
manager = man;
|
manager = man;
|
||||||
|
connection = conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -72,7 +73,7 @@ printf("ThreadID is written %d %p %p %p %p\n",paramCount, call, mon, manager, th
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
manager->SendUrpRequest(oid, iid, mid, interfaceInfo, call, paramCount,
|
manager->SendUrpRequest(oid, iid, mid, interfaceInfo, call, paramCount,
|
||||||
info);
|
info, connection);
|
||||||
if(NS_FAILED(PR_Wait(mon, PR_INTERVAL_NO_TIMEOUT))) {
|
if(NS_FAILED(PR_Wait(mon, PR_INTERVAL_NO_TIMEOUT))) {
|
||||||
printf("Can't wait on cond var\n");
|
printf("Can't wait on cond var\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
|
|
|
@ -30,11 +30,12 @@
|
||||||
|
|
||||||
class urpStub : public bcIStub {
|
class urpStub : public bcIStub {
|
||||||
public:
|
public:
|
||||||
urpStub(urpManager* man);
|
urpStub(urpManager* man, urpConnection* con);
|
||||||
virtual ~urpStub();
|
virtual ~urpStub();
|
||||||
virtual void Dispatch(bcICall *call) ;
|
virtual void Dispatch(bcICall *call) ;
|
||||||
private:
|
private:
|
||||||
urpManager* manager;
|
urpManager* manager;
|
||||||
|
urpConnection* connection;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Загрузка…
Ссылка в новой задаче