This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
i have a cpp program which has the functionalities of a sip phone.
we are using pjsip stack
the program runs fine with all functionalities in sip phone and in command prompt mode.
now we have to integrate with java using jni to have a interface for the sip phone.
we have succeeded in initializing the stack( registering with the server), placing call, answering call, hanging up a call and releasing( unregistering).
while we place call, the following method in cpp gets automatically called at the reciever end.
the above method has some coding on what to do with the incoming call and some interactive things like
now we are struck up with this part for the past 1 week.
all we need to do is to have the above interactive part to be called from the java program.
for that we need to write a method for that part in java.
but the problem is that the method is automatically called when we place a call ( when some one recieves a call).so we donot need to write a native method for that in java.
it would be easier if we write a native method for the above method in java(because all the things will be called once the method is called, so do the interactive part of the method).
but we want it to be run from java.
If I get the problem correctly, the native C++ code is raising events outside Java, and you want the Java code to handle those events. Am I right?
This C++ function should have a reference to the JVM (JNIEnv*) and the object on which to call the method. It can then use functions like GetMethodID and CallVoidMethod to call that method from Java. You will need to convert the parameters to the C++ function to something Java understands though.
In pseudo code:
As you see this would require ways to convert the C++ data types to Java data types and vice versa, and you're going from native code to Java code back to native code.
let me make it even more clear.
now when we run the java program in eclipse we get the gui and we can initialize the stack,place call, hang call and release the queue(unregister from server)
so when we place a call the automatically will get called which have
so we get "type a to answer the call" in the eclipse output window.
what we want is, instead of typing a in eclipse output window we want to press a button in the gui which does the function of typing a in the output eclipse window.
hope i'm more clear now.
thanks in advance
Joined: Apr 06, 2009
at the time i posted my second reply your reply was not there. that is why i posted the reply making more clear idea..
i suppose you got it right.. as far as i'm concerned what you is said is exactly what i want. but who knows, if my team lead accepts this or not....
anyways thank you very much for the exact answer....
i may reply again if that procedure is not accepted.