Package javax.microedition.io

Examples of javax.microedition.io.StreamConnection


        discoveredServices.addElement(serviceRecord);

        try {
            // W tym miejscu nawiazuje sie polaczenie z serwerem.
            //TODO wyjebac stad i stworzyc klase agregujaca polacenie miedzy serwerem a klientem
            StreamConnection conn = (StreamConnection) Connector.open(serviceRecord.getConnectionURL(ServiceRecord.NOAUTHENTICATE_NOENCRYPT, false));
            new MessagingForm(bTMIDlet, new BTConnection(conn));
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
View Full Code Here


                // Tworzymy obiekt ktory bedzie czekal na polaczenie
                streamConnectionNotifier = (StreamConnectionNotifier) Connector.open("btspp://localhost:" + serviceUUID + ";name=" + localName + connectionParameters);
                form.append("\nOtworzono Connector");
                // Ta linia uruchamia metode synchronizowana. Dopoki polaczenie nie zostanie nawiazane, watek stoi tutaj.
                // nawiazanie polaczenia nastepuje w momencie otworzenia URL u klienta
                StreamConnection streamConnection = streamConnectionNotifier.acceptAndOpen();
                form.append("\nacceptAndOpen()");
                // Obowiazkowo zamykamy obiekt czekajacy na polaczenie
                streamConnectionNotifier.close();
                form.append("\nnotifier.close()");
                // Konczymy zadanie Timera
View Full Code Here

                    DataListener listener = manager.getDataListener();
                    while (listening) {

                        if (!paused) {

                            StreamConnection get = server.acceptAndOpen();
                            //#ifdef DEBUG
                            System.out.println("Connected");
                            //#endif
                            listener.addConnetion(get);
                            if (listener.getNumberListener() == 3) {
View Full Code Here

                out.close();
                out = null;
            } catch (Exception e) {}
            try {

                StreamConnection con = (StreamConnection) connections.elementAt(c);
                con.close();
                con = null;
            } catch (Exception e) {}
        }

        inputStreams.removeAllElements();
View Full Code Here

        new Thread() {

            public void run() {
                try {

                    StreamConnection con = (StreamConnection) Connector.open(service.
                                            getConnectionURL(ServiceRecord.NOAUTHENTICATE_NOENCRYPT,
                                                             false));
                    new MultiPlayerManager(mid, name).getDataListener().
                                           addConnetion(con);
                } catch (IOException ex) {
View Full Code Here

        // Create message processing thread, and run it
        MessageProcessor messageProcessor = new MessageProcessor();
        messageProcessor.start();

        while( !_stop ) {
            StreamConnection stream = null;
            InputStream input = null;
            DataBuffer db = null;
            try {
                /**
                 * Does this need to be synch'd? This should be a single threaded instance that runs autonomously on a port.
                 *
                 * Might want to call this in the the PushService class to catch IOPortAlreadyBoundException so we can properly
                 * throw this back up via JavaScript so the developer realizes that the port they tried to open is unavailable.
                 */
                synchronized( this ) {
                    _notify = (StreamConnectionNotifier) Connector.open( getURL() );
                }

                while( !_stop ) {
                    // block for data
                    stream = _notify.acceptAndOpen();
                    try {
                        // create input stream
                        input = stream.openInputStream();

                        // extract the data from the input stream
                        db = new DataBuffer();
                        byte[] data = new byte[ CHUNK_SIZE ];
                        int chunk = 0;
                        while( -1 != ( chunk = input.read( data ) ) ) {
                            db.write( data, 0, chunk );
                        }

                        // trim the array - the buffer in DataBuffer grows
                        // past the size and fills with empty chars
                        db.trim();

                        // synchronize this block to avoid race conditions with the queue
                        synchronized( _messageQueue ) {
                            // Create push object, add to queue for callback thread
                            PushData pd = new PushData( stream, input, db.getArray() );
                            _messageQueue.addElement( pd );
                            _messageQueue.notify();
                        }
                    } catch( IOException e1 ) {
                        // a problem occurred with the input stream
                        // however, the original StreamConnectionNotifier is still valid
                        if( input != null ) {
                            try {
                                input.close();
                            } catch( IOException e2 ) {
                            }
                        }
                        if( stream != null ) {
                            try {
                                stream.close();
                            } catch( IOException e2 ) {
                            }
                        }
                    }
                }
View Full Code Here

     *
     * @return network stream connection
     * @exception IOException is thrown if the connection cannot be opened
     */
    protected StreamConnection connect() throws IOException {
        StreamConnection sc;
        com.sun.midp.io.j2me.socket.Protocol conn;

        if (!permissionChecked) {
            throw new SecurityException();
        }
View Full Code Here

        return clients.size() > 0;
    }

    public void connect() {
        try {
            StreamConnection client = server.acceptAndOpen();
            GRTSingleConnect c = new GRTSingleConnect(client);
            c.start();
            clients.addElement(c);
            notifyConnect(c);
        } catch (Exception e) {
View Full Code Here

        return clients.size() > 0;
    }

    public void connect() {
        try {
            StreamConnection client = server.acceptAndOpen();
            GRTSingleConnect c = new GRTSingleConnect(client);
            c.start();
            clients.addElement(c);
            notifyConnect(c);
        } catch (Exception e) {
View Full Code Here

      // expected
          
            Dialog.show("", Contents.done, null, Dialog.TYPE_INFO,null, 3000);
      //bisogna richiamare getguiconv?

        StreamConnection fconn = (StreamConnection)Connector.open(locator);
        InputStream is = fconn.openInputStream();
        String type = "";
       
        if (is_image) {
            try {
                form.addComponent(BorderLayout.CENTER, new Label(Contents.displayImage(is)));
View Full Code Here

TOP

Related Classes of javax.microedition.io.StreamConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.