BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 02-17-2010, 05:06 AM   #1 (permalink)
Thumbs Must Hurt
 
Join Date: May 2007
Location: berlin, germany
Model: 8310
PIN: N/A
Carrier: vodafone
Posts: 163
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Push Data to BlackBerry (TCP)

Please Login to Remove!

Hi,
some time ago I asked for a TCP listener on Blackberry (TCP Listener). This Topic was closed, so I have to start a new one.

The last Post is about pushing some data over http to the BB. The Example link sounds interesting, but I have no idea about the parameters http://server:port/push?DESTINATION={dest}&PORT=7874&

Are there any changes for the BES?
Which port do I have to use for Index of / ?
Which value should {dest} have, the pin of the device?

Maybe someone can answer my questions and help me

thanks
__________________
My English is so bad, that makes me nobody so quickly after
Offline  
Old 02-17-2010, 12:41 PM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Post Thanks: 20
Thanked 77 Times in 68 Posts
Default

Quote:
Originally Posted by hibbert View Post
Hi,
some time ago I asked for a TCP listener on Blackberry (TCP Listener). This Topic was closed, so I have to start a new one.

The last Post is about pushing some data over http to the BB. The Example link sounds interesting, but I have no idea about the parameters http://server:port/push?DESTINATION={dest}&PORT=7874&

Are there any changes for the BES?
I don't know what you are asking here.
Quote:
Which port do I have to use for Index of / ?
This is the port of the MDS server associated with the BES, usually 8080 IIRC
Quote:
Which value should {dest} have, the pin of the device?
This is the PIN of the device or the email address associated with the device on the BES.
Quote:
Maybe someone can answer my questions and help me

thanks
__________________
My other Blackberry is a PlayBook.
Offline  
Old 02-23-2010, 09:24 AM   #3 (permalink)
Thumbs Must Hurt
 
Join Date: May 2007
Location: berlin, germany
Model: 8310
PIN: N/A
Carrier: vodafone
Posts: 163
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by hrbuckley View Post
I don't know what you are asking here.
I don't know what happend there... i shouln'd work and post at the same time...

i wanted to know which port I have to use in Index of /, but you already have answerd it ;)

I will try it. Thanks for your help.

If I have more questions I will come back
__________________
My English is so bad, that makes me nobody so quickly after
Offline  
Old 02-24-2010, 02:36 AM   #4 (permalink)
Thumbs Must Hurt
 
Join Date: May 2007
Location: berlin, germany
Model: 8310
PIN: N/A
Carrier: vodafone
Posts: 163
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
OK, it works
But I still have one problem and one question left:

First the problem: I have used your Code from the other Post. That works fine, but the StreamConnection is always null. Maybe it can be solved with my other question:

I want to push some Data onto my BB, so that I get a String in my Application. What do I have to push to the Device? Are there more Parameters (i couldn't find some more) or which Headers do I have to use?

Thanks again

hibbert
__________________
My English is so bad, that makes me nobody so quickly after
Offline  
Old 02-24-2010, 09:00 AM   #5 (permalink)
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Post Thanks: 20
Thanked 77 Times in 68 Posts
Default

Who's code, from which post?
__________________
My other Blackberry is a PlayBook.
Offline  
Old 03-09-2010, 02:11 AM   #6 (permalink)
Thumbs Must Hurt
 
Join Date: May 2007
Location: berlin, germany
Model: 8310
PIN: N/A
Carrier: vodafone
Posts: 163
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have used the Example of my Last Post (TCP Listener).

I start the push within the internet explorer or with a simple httprequest from VB.net.
__________________
My English is so bad, that makes me nobody so quickly after
Offline  
Old 03-17-2010, 10:29 AM   #7 (permalink)
Thumbs Must Hurt
 
Join Date: May 2007
Location: berlin, germany
Model: 8310
PIN: N/A
Carrier: vodafone
Posts: 163
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
ok, with this function i can receive Data on my BB.
Code:
/**
     * The listener thread, listens for push data from the MDS.
     * it is usually better to do TCP communications in a separate thread
     */
    static class ListenerThread extends Thread
    {
        private boolean stopThread;
        private StreamConnectionNotifier notify;
        private StreamConnection stream;
        private InputStream input;
        
        ListenerThread()
        {
            super();
            stopThread = false;
            notify = null;
            stream = null;
            input = null;
        }
        
        public void stop()
        {
            synchronized(this)
            {
                stopThread = true;  // set the flag to stop the thread.
                
                // if the stream is null (no input happening) but notify isn't

                if (stream == null && notify != null)
                {
                    try
                    {
                        notify.close(); // close the listening socket
                    }
                    catch (Exception e)
                    {
                        System.err.println(e.toString());
                    }
                }
            }
            
            try
            {
                join(); // wait until the thread completes.
            }
            catch (Exception e) {}
            
        }
        
        public void run()
        {
            synchronized(this)
            {
                // this sleep shouldn't be necessary, but it helps to stagger 
                // threads if you start lots in an auto run application
                try
                {
                    sleep(1000L);
                }
                catch (Exception e)
                {
                }
                
                System.out.println("background thread -- running");
            }
            
            try
            {
                // Create a stream connection notifier on http protocol (for push)
                // and the port we want to use.
                notify = (StreamConnectionNotifier)Connector.open("http://:555");
                
                
                
                while (!stopThread)
                {
                    // block until data is received
                    stream = notify.acceptAndOpen();

                    synchronized(this)
                    {
                        if (stopThread)
                            break;
                        input = stream.openInputStream();
                    }
                    
                    someFunctionToProcess(input);
                    stream.close();
                    stream = null;
                    input = null;
                }
            }
            catch (Exception e)
            {
                System.err.println(e.toString());
            }
        }
    }
Now I have tried to send back a String, like this:
Code:
try {
                    OutputStream os = stream.openOutputStream();
                    byte[] theByteArray = ((String)"ACK").getBytes("UTF-8");
                    os.write(theByteArray);
                    os.flush();
                    os.close();
                    os = null;
                } catch (Exception ex) {
                    System.out.println(ex.toString());
                }
How Can I send back a Message to the sender, e.g. an "ACK"?

thanks hibbert
__________________
My English is so bad, that makes me nobody so quickly after
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.