How to 'unlock' push to listen (acceptAndOpen)

Hi I have tried to find a way to do every morning and google on this topic without finding a good answer.

I have an application that continuously listening one pushes a bes server. Now, I need to change to listen pushes for a period of time. After this time, I have to stop listening (and treat the push messages but it's not the case.)

Set a time-out seems to work only when a connection is already open, so it's not help.

Finally, I tried to run a Thread just before the call to 'acceptAndOpen '. This Thread waits for a while and if nothing is received then it try to call to 'close' the connection, but all I get is a "Invalid PDAP queue state" in the Simulator. I provide the part of the code for more details.

StreamConnection stream = null;InputStream input = null;MDSPushInputStream pushInputStream = null;

[...]

while (!stop) {    try {    

        [...]

        synchronized (this) {

//                    scn = (StreamConnectionNotifier) Connector.open(URL + ";ConnectionTimeout=30000;deviceside=false",Connector.READ,true);            ConnectionFactory connFact = new ConnectionFactory();            ConnectionDescriptor connDesc = connFact.getConnection(URL + ";deviceside=false");            connFact.setConnectionTimeout(30000);            scn = (StreamConnectionNotifier) connDesc.getConnection();        }

        AccepConnectionTimeout thread = null;        while (!stop) {            try {                // NOTE: the following will block until data is received.                thread = new AccepConnectionTimeout(scn);                thread.start();                stream = scn.acceptAndOpen();            } catch (InterruptedIOException  iioe) {                Log.error(ERR_TAG + "Timeout waiting connection:" + iioe.getMessage());                scn.close();                scn = null;                // TODO do something here                continue;            }

            timestampUltimaRecepcion = System.currentTimeMillis();

[...]

public class AccepConnectionTimeout extends Thread {public boolean stop = false;public StreamConnectionNotifier scn = null;

public AccepConnectionTimeout(StreamConnectionNotifier scn) {    this.scn = scn;}

public void run() {    try {        Thread.sleep(30000);    } catch (Exception e) {        Log.error(ERR_TAG + "Error waiting for accept timeout");    }    if (!stop) {        try {            scn.close();        } catch (IOException ioe) {            Log.error(ERR_TAG + "Error closing connection after accept timeout:" + ioe.getMessage());        } catch (Exception e) {            Log.error(ERR_TAG + "(Exception)Error closing connection after accept timeout:" + e.getMessage());        }    }}

[...]

(NOTE: I only ran this in a simulator)

I can't find much information on this 'mistake' and also my main goal is to achieve the objective referred to in the second subparagraph. Could you help me somehow? How to do this? How to solve it? examples?

I'm not sure that understand your condition.

Normally what you would do if have an earpiece for push messages, and whenever a message is received, it starts a new Thread and pass the received data.  So I don't understand the problem with this:

"After this time I have to stop listening (and treat the push messages.

Adoption of the approach to treatment that I mentioned will ensure that pushed messages are processed as they are received, which seems the right thing to do.

As do you this, then I think that the obligation to stop the listener disappears.

Sorry I don't have any comment on your post, just this part of your application design.

Tags: BlackBerry Developers

Similar Questions

  • How to unlock my computers keyboard laptop hp

    How to unlock my laptop keyboard hp mothers. Ive looked everywhere on the net and the answers I get is to push the buttons f # and the key fn at the same time, but she didn't and the f button #.  Please help me.   Thank you

    I don't think that its coastline you just need a password to connect... my laptop as a touch both fn and I use it to lock my phone but I just type my password to log in... I found a page that says if your keyboard does not work is to turn off the unit, remove the battery and leave it aside for a minute and then put battery back in then reboot the machine,... try this

  • How to unlock the sim?

    How the sim card unlock iphone6?

    How to unlock your iPhone - Apple Support

  • How to unlock my iphone 5, because my contract has expired?

    How to unlock my iphone5 because my contract has expired? Thank you.

    Hey nebo700,

    Thanks for posting your question in the Community Support from Apple! I understand you want to unlock your iPhone for use with another carrier. I can certainly understand wanting to be able to use the carrier of your choice, and I am happy to share information.

    You will be able to find all the information on how to unlock your iPhone here: How to unlock your iPhone

    See you soon!

  • How to unlock my book mac pro with my watch i

    How to unlock my book mac pro with my watch i

    The watch must be update shows OS 3, and MacBook to macOS Sierra.  Then go on the MacBook in settings-> Security & privacy-> and select "Allow Apple Watch unlock your mac".

  • How to unlock my laptop drive

    I downloaded mac os sierra and he said which drive you want to download this to and I clicked on the single disc he called untitled but then he said: this disk is locked. I also tried to reinstall os x before, and he also said that he is blocked how I unlocked.

    Open Terminal.app, and then type

    sudo chflags 0/volumes / *.

    Type your password

    sudo chmod a + rx/volumes / *.

    Type your password

  • How to unlock your Mac with your Apple Watch

    Hello

    How to unlock your Mac with your Apple Watch?

    my mac: MacBook Pro (13 inch, late 2011) MacOS Sierra 10.12

    I can not found "Allow your Apple Watch unlock your Mac" in security and privacy


    Thank you



    .

  • How to unlock my other apple if I forgot my password of previous email?

    How to unlock my other apple if I forgot my password of previous email? ... Please help. I know my apple ID and pass but when I log-in to apple.com, he says that she must be unlocked by security question and e-mail. I can't answer the security questions because I forgot those and I'm not the one who has created, for the one who created it forgot (lol). I can't get access because I forgot the password to the e-mail address. If I try to reset my email pass. Yahoo will not allow him. but in another email it help. Help, please

    If you do not access your email from backup, you should contact Apple support to unlock your Apple ID.

    Contact Apple for support and service - Apple Support

  • My calendar settings are locked. How to unlock them?

    I can't add new events and properties of calendar, on the Edit drop-down list selection is grayed out. How to unlock my settings so that I can add one more time of the events.

    You have the calendar set to read-only? Are there symbols of the lock next to your calendar in the Calendar pane?

    Click with the right button on the calendar in the Calendar pane, and then select Properties. Then uncheck ready only.

  • How to unlock an ipad after reset of the manufacturer?

    How to unlock an iPad after reset of a manufacturer.  Purchased from a third party and do not know the original owner.

    Without the previous owner Apple ID and password, the iPad doesn't help. Not even Apple can help you.

    Get your money back if you can.

  • Qwall paper screen is locked up how to unlock

    In order to install a screen wall for my homescreen he locked how to unlock?

    Reboot your iPad.

    1. Press and hold the sleep/wake button until the Red slider appears.
    2. Drag the slider to turn off your device completely off.
    3. Once the device turns off, press and hold the sleep/wake button again until you see the Apple logo.
  • How to unlock the phone with broken screen?

    The screen on my Keon is broken. Fortunately, it still meets the touch. Just in case, I wonder:

    How would unlock my Firefox OS phone if it no longer meets the touch?

    I'm running 1.3 on my Keon, and my flame (always good screen!), it's the 3.0 nightly.

    On Android, you can connect a mouse: https://www.youtube.com/watch?v=TTW0yfol_kQ

    Hi Fekle,

    Unfortunately, it is not possible to connect a mouse to Firefox OS. You can write to our advocacy team to suggest new features and provide feedback on your use of Firefox OS:

    I also already asked B2G teams if it is possible to recover a phone without the password. The answer short, is that for security reasons, it is not possible.

    I hope you find this information useful. Please let us know if you have other questions about your Firefox OS device.

    -Ralph

  • Content blocked by AdBlock. How to unlock?

    I try to go to a Web page and got this message

    Content blocked by AdBlock.
    Part of the advertising content is blocked by an extension of the browser.

    I have not yet installed an adblocker. How can this happen? And how to unlock the content?

    You can try the following steps in case of problems with web pages:

    You can reload webpages and ignore the cache to refresh potentially stale or corrupt.

    • Hold down the SHIFT key and click the Reload button
    • Press 'Ctrl + F5' or 'Ctrl + Shift + R' (Windows, Linux)
    • Press 'Command + shift + R' (Mac)

    Clear the cache and delete cookies only from Web sites that cause problems.

    "Clear the Cache":

    • Firefox/tools > Options > advanced > network > content caching Web: 'clear now '.

    'Delete Cookies' sites causing problems:

    • Firefox/tools > Options > privacy > "Use the custom settings for history" > Cookies: "show the Cookies".

    Start Firefox in Safe Mode to check if one of the extensions (Firefox/tools > Modules > Extensions) or if hardware acceleration is the cause of the problem.

    • Put yourself in the DEFAULT theme: Firefox/tools > Modules > appearance
    • Do NOT click on the reset button on the startup window Mode safe
  • How to unlock my iphone 6 icloud

    1. Hello, I'm Xhulian Lici.
      I am writing because I locked my iphone with icloud id, my friend I Don this iphone 6 but was locked with icloud I want to unlock my iPhone from iCloud, but first of all, how I unlock my iphone and secondly I did not have enough money to pay the payment for this reason that I want you to now without money after I promise you I'll send my money when I have money to my family. which means that in the other months, but I need my iphone now to lesson.please help me I am from Albania and my economic status isn't right please help m

    Post edited by: xhulinjo

    The only person who can unlock the phone, it's the person who's Apple ID was used to lock. You will need to contact your friend.

  • I bought a second hand iPhone model6 more. I couldn't open it because it has been locked the former owner with lost or stolen message. I don't know who was the real owner. Last owner who sold me was expired. Cannot find the true owner. How to unlock

    Bought a second hand iphone 6, who is locked with "Find my iPhone". Is not the real owner of the iPhone. How to unlock to use and save my money?

    Without the Apple ID and password, the iPhone is useless for you. No, not even Apple can unlock it. I'm sorry.

Maybe you are looking for

  • Firefox keeps crushing at the launch of the new tab.

    I just installed Windows 10 and I can open a new firefox window without crashing, but when I open a new tab, it crashes. Every time. It is not do it in safe mode and I tried to uninstall and reinstall. I also tried disabling all my addons. Here are t

  • Need driver sound for Satellite A65

    Had to not reinstall OS now now no sound... checked and found this driver is missing and can't find it.If someone can help a lot...

  • Add an internal hard drive to h8-1234

    I would like to add a second SATA internal hard drive to my desktop H8-1234.  What kind of additional cables do need me and where I can find a ppicture, etc. where he and the reader goes?

  • How to save a scanned as PDF document?

    How can I save a document scanned in PDF format.  I use a Photosmart C6280.

  • Cannot download images from Canon to the computer

    I have a new Dell running Windows 7.  I installed the software for my Canon PowerShot SD550 camera, but I can't download photos from my camera to the computer.  I tried to uninstall, but it won't let me.  Is this a compatibility issue.  I have a came