I want to get and read sip info messages on during call. I sent other side to sip info message and I saw on logcat but I dont get the message on code. I use the pjsip.
How to get sip info messages on during call?
Thanks.
you will require. onCallTsxState call back function from call class to listen to Sip message shared during the call. It took quite some time for me to figure out and hopefully it could help some once else ,if its too late for you.
#Override
public void onCallTsxState(OnCallTsxStateParam prm) {
if (eventBody.getTsxState().getType() == (pjsip_event_id_e.PJSIP_EVENT_RX_MSG)) {
SipRxData rdata = eventBody.getTsxState().getSrc().getRdata();
//technically here in messageBuffer I am storing all header file info shared during the call
String messageBuffer = rdata.getWholeMsg();
Log.e("bingo", String.valueOf(messageBuffer));
// in my case in my case I am check presences of info message : Connection Established every time new header message is send
if(messageBuffer.contains("Connection established")){
Log.e("bingo", "bingo established");
try {
//perform what ever you want to do here when you receive info message
}
});
Related
We are developing an app which needs to interact with various opperators USSD menus. (USSD is GSM's Unstructured Supplementary Service Data). I have searched and searched for a solution to no avail. It may not be possible.
We need to be able to initiate a ussd session, e.g. dial *150*00#
Phone receives USSD response - ideally we hide or automate a response immediately so it simply flashes in and out.
We automate a response, and more often a series of response, receive, response until complete.
The app then scrapes in the automated sms received.
This needs to work ideally for android versions pre oreo and post, so I presume using accessibility services pre and the ussd api post. API 26 seems to work ok for a 1 step receive response but from what I read not for multiple steps.
Any help most appreciated.
You can use this library for multi step ussd https://github.com/romellfudi/VoIpUSSD. It leverages accessability service for scraping, filling and dismissing ussd dialogs
Say you want to perform this ussd sequence *122# -> 1 -> final result
This is how you can do it
USSDApi ussdApi = USSDController.getInstance(context);
ussdApi.callUSSDInvoke("*122#", map, new USSDController.CallbackInvoke() {
#Override
public void responseInvoke(String message) {
// message has the response for *122#
ussdApi.send("1", new USSDController.CallbackMessage(){
#Override
public void responseMessage(String message) {
// message has the response for 1
}
});
}
#Override
public void over(String message) {
// message contains the final result
}
});
I'm trying to send an event or better a message to the mobile while the wearable is disconnected.
Here is the code I'm using:
Wearable.MessageApi.sendMessage(
mGoogleApiClient, node, event, message).setResultCallback(
new ResultCallback<MessageApi.SendMessageResult>() {
#Override
public void onResult(MessageApi.SendMessageResult sendMessageResult) {
if(!sendMessageResult.getStatus().isSuccess()) {
Log.e(TAG, "Failed to send message with status code: "
+ sendMessageResult.getStatus().getStatusCode());
}
}
}
);
The node ID is cached when onPeerConnected(Node peer) is called so I don't need to query the Node API to get an empty list. However I send the data to the node which is offline. That results the StatusCode 4000 which is TARGET_NODE_NOT_CONNECTED. Of course I know that, but what is the best way to cache this event to send it as soon as possible?
I ended in the that idea which Maciej Ciemięga pointed out in the comments. I'm using the DataAPI to store and forward my events. After the event was recieved by the mobile I delete the path from the data layer, since it did its job.
You should keep in mind the deletion will invoke again the onDataChanged method. So you should check the type of the DataEvent:
event.getType() == DataEvent.TYPE_DELETED
If you don't keep that in mind you may get an infinity loop.
please help.
I have two WearableListenerServices. The first on phone and the second on a watch. if I send asset data from wear to phone, for example:
PutDataMapRequest dataMap = PutDataMapRequest.create(AUDIO_PATH);
dataMap.getDataMap().putAsset(REC_AUDIO_KEY, asset);
dataMap.getDataMap().putLong(TIME, new Date().getTime());
dataMap.getDataMap().putString(NAME, name);
PutDataRequest request = dataMap.asPutDataRequest();
Wearable.DataApi.putDataItem(mGoogleApiClient, request).setResultCallback(new ResultCallback<DataApi.DataItemResult>() {
#Override
public void onResult(DataApi.DataItemResult dataItemResult) {
if (!dataItemResult.getStatus().isSuccess()) {
failRecord();
}else{
successRecord(true);
}
}
});
I expect that result will be from phone, but in fact response come back from itself. The problem is that on the watch executed method onDataChanged earlier then on the Phone. How can I send request only to other device?
Thanks.
Have u cross checked the path (AUDIO_PATH) ? It should be same in onDataChanged of wearableListenerService located in phone and not to be same in onDataChanged of wearableListenerService located in Wear.
In your question you have already mentioned that u need to send request to only one side then u dont have to implement onDataChangedMethod in Sending side.
I am using SmartFox Server and want to check if the Server is ready to accept requests or not.According to my searchings in the available documentation and google..the way to do this by using a event handler on the server stating which kind of event needs to be handled or a certain block of code that needs to be executed when that event is fired..An event SERVER_READY is available to use..but how do i send a response to the client is what i am stuck at..this is the code so far..
In my extension..
addEventHandler(SFSEventType.SERVER_READY, ServerReadyHandler.class );
And the handler class..
public class ServerReadyHandler extends BaseServerEventHandler{
MyExtension ade=null;
ISFSObject resp_obj=null;
#Override
public void handleServerEvent(ISFSEvent event) throws SFSException
{
ade=(AdminExtension) getParentExtension();
if(event.getType().equals(SFSEventType.SERVER_READY))
{
// response needs to be send to the client that server is ready..
}
}
}
my client side is in android java...
Lets Consider these
SERVER_READY will fire only once in entire lifecycle of Smartfox per extension, so you can't fire any event to client from there.
SmartFox class of client library has following methods and events to determine server status
a) isConnected()
b) isConnecting()
c) SFSEvent.CONNECTION
d) SFSEvent.CONNECTION_LOST
e) SFSEvent.LOGIN
f) SFSEvent.LOGIN_ERROR
here methods a) b) will specify whether the smartfox server(not your extension server) is connected or not.
c),d) events will fire when ever the sfs.connect(ip,port); fired from client.
When ever the client need to connect with your join it will sends a request to your zone as LoginRequest(username,password,zonename)
if your zone is not in active or there is no zone with that name the smartfox automatically fires SFSEVENT.Login_error will fires.
if your zone is active then your zone extension's SFSEventType.USER_LOGIN will fired according to your coding client will get either of LOGIN/LOGIN_ERROR events.
If you need the sample code then I will send. Please go with smartfox documentation.
I am explaining bluetooth chat example and trying to find a way to make one device only able to write after it gets a message from other device. e.g. 1st device connects to 2nd device, so 2nd device cant write (send message) until it gets message from 1st device. Tried to do some searching but found nothing... Maybe anyone could help me with this? Example changes in code would be appreciated.
Thanks in advance.
I am not aware of any mechanism provided by bluetooth, that will help you to accomplish, what you are trying to implement.
But you can do something like that
class YourClass {
private boolean allowedToSend = false;
private void send() {
if(allowedToSend) {
allowdToSend = false;
//Sending your data
}
}
private void receive() {
allowdToSend = true;
//receiving your data
}
}