亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? serverform.java

?? J2ME MIDP_Example_Applications
?? JAVA
字號:
// Copyright 2004 Nokia Corporation.
//
// THIS SOURCE CODE IS PROVIDED 'AS IS', WITH NO WARRANTIES WHATSOEVER,
// EXPRESS OR IMPLIED, INCLUDING ANY WARRANTY OF MERCHANTABILITY, FITNESS
// FOR ANY PARTICULAR PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE
// OR TRADE PRACTICE, RELATING TO THE SOURCE CODE OR ANY WARRANTY OTHERWISE
// ARISING OUT OF ANY PROPOSAL, SPECIFICATION, OR SAMPLE AND WITH NO
// OBLIGATION OF NOKIA TO PROVIDE THE LICENSEE WITH ANY MAINTENANCE OR
// SUPPORT. FURTHERMORE, NOKIA MAKES NO WARRANTY THAT EXERCISE OF THE
// RIGHTS GRANTED HEREUNDER DOES NOT INFRINGE OR MAY NOT CAUSE INFRINGEMENT
// OF ANY PATENT OR OTHER INTELLECTUAL PROPERTY RIGHTS OWNED OR CONTROLLED
// BY THIRD PARTIES
//
// Furthermore, information provided in this source code is preliminary,
// and may be changed substantially prior to final release. Nokia Corporation
// retains the right to make changes to this source code at
// any time, without notice. This source code is provided for informational
// purposes only.
//
// Nokia and Nokia Connecting People are registered trademarks of Nokia
// Corporation.
// Java and all Java-based marks are trademarks or registered trademarks of
// Sun Microsystems, Inc.
// Other product and company names mentioned herein may be trademarks or
// trade names of their respective owners.
//
// A non-exclusive, non-transferable, worldwide, limited license is hereby
// granted to the Licensee to download, print, reproduce and modify the
// source code. The licensee has the right to market, sell, distribute and
// make available the source code in original or modified form only when
// incorporated into the programs developed by the Licensee. No other
// license, express or implied, by estoppel or otherwise, to any other
// intellectual property rights is granted herein.


package example.btsppecho;


import java.io.IOException;
import java.util.Vector;

import javax.bluetooth.BluetoothStateException;
import javax.bluetooth.LocalDevice;
import javax.bluetooth.ServiceRecord;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Item;
import javax.microedition.lcdui.StringItem;
import javax.microedition.lcdui.TextField;

import example.btsppecho.server.ServerConnectionHandler;
import example.btsppecho.server.ServerConnectionHandlerListener;


class ServerForm
    extends Form
    implements ServerConnectionHandlerListener, CommandListener
{
    private final MIDletApplication midlet;
    private final StringItem numConnectionsField;
    private final TextField sendDataField;
    private final StringItem receivedDataField;
    private final StringItem statusField;
    private final Command sendCommand;
    private final Command addConnectionCommand;
    private final Command searchCommand;
    private final Command logCommand;
    private final Command quitCommand;
    private final Command clearStatusCommand;
    private final Vector handlers;

    private int maxConnections;
    private StringItem btAddressField = null;
    private volatile int numReceivedMessages = 0;
    private volatile int numSentMessages = 0;
    private int sendMessageId = 0;


    ServerForm(MIDletApplication midlet)
    {
        super("Server");
        this.midlet = midlet;
        handlers = new Vector();

        String value =
            LocalDevice.getProperty(
                            "bluetooth.connected.devices.max");
        try
        {
            maxConnections = Integer.parseInt(value);
        }
        catch (NumberFormatException e)
        {
            maxConnections = 0;
        }

        // 1. add Form items
        try
        {
            String address = LocalDevice.getLocalDevice()
                                        .getBluetoothAddress();
            btAddressField = new StringItem("My address", address);
            append(btAddressField);
        }
        catch (BluetoothStateException e)
        {
            // nothing we can do, don't add field
        }
        numConnectionsField = new StringItem("Connections", "0");
        append(numConnectionsField);
        statusField = new StringItem("Status", "");
        append(statusField);
        sendDataField = new TextField("Send data",
                                      "Server says: 'Hello, world.'",
                                      64,
                                      TextField.ANY);
        append(sendDataField);
        receivedDataField = new StringItem("Last received data",
                                           null);
        append(receivedDataField);


        // 2. create commands
        sendCommand = new Command("Send", Command.SCREEN, 1);
        searchCommand = new Command("Search for more",
                                    Command.SCREEN,
                                    1);
        addConnectionCommand = new Command("Add connection",
                                           Command.SCREEN,
                                           2);
        logCommand = new Command("View log", Command.SCREEN, 3);
        clearStatusCommand = new Command("Clear status", Command.SCREEN, 4);
        quitCommand = new Command("Quit", Command.EXIT, 1);


        // 3. add commands and set command listener
        addCommand(searchCommand);
        addCommand(addConnectionCommand);
        addCommand(logCommand);
        addCommand(clearStatusCommand);
        addCommand(quitCommand);
        // The 'sendCommand' is added later to screen,
        // if at least one connection is open.
        setCommandListener(this);
    }


    public void makeConnections(Vector serviceRecords, int security)
    {
        for (int i=0; i < serviceRecords.size(); i++)
        {
            ServiceRecord serviceRecord =
                (ServiceRecord) serviceRecords.elementAt(i);
            boolean found = false;
            for (int j=0; j < handlers.size(); j++)
            {
                ServerConnectionHandler old =
                    (ServerConnectionHandler) handlers.elementAt(j);
                String oldAddr = old.getServiceRecord().
                                     getHostDevice().
                                     getBluetoothAddress();
                String newAddr =
                       serviceRecord.getHostDevice()
                                    .getBluetoothAddress();
                if (oldAddr.equals(newAddr))
                {
                     found = true;
                     break;
                }
            }
            if (!found)
            {
                ServerConnectionHandler newHandler =
                    new ServerConnectionHandler(
                            this,
                            serviceRecord,
                            security);
                newHandler.start(); // start reader & writer
            }
        }
    }


    private void removeHandler(ServerConnectionHandler handler)
    {
        if (handlers.contains(handler))
        {
            handlers.removeElement(handler);
            String str = Integer.toString(handlers.size());
            numConnectionsField.setText(str);
            if (handlers.size() == 0)
            {
                removeCommand(sendCommand);
                addCommand(searchCommand);
            }
        }
    }


    void closeAll()
    {
        for (int i=0; i < handlers.size(); i++)
        {
            ServerConnectionHandler handler =
                (ServerConnectionHandler) handlers.elementAt(i);
            handler.close();
            removeHandler(handler);
        }
    }


    public void commandAction(Command cmd, Displayable disp)
    {
        if (cmd == addConnectionCommand)
        {
            Vector v = new Vector();
            for (int i=0; i < handlers.size(); i++)
            {
                ServerConnectionHandler handler =
                    (ServerConnectionHandler) handlers.elementAt(i);
                String btAddress = handler.getServiceRecord()
                                       .getHostDevice()
                                       .getBluetoothAddress();
                v.addElement(btAddress);
            }
            midlet.serverFormAddConnection(v);
        }
        else if (cmd == clearStatusCommand)
        {
            statusField.setText("");
        }
        else if (cmd == logCommand)
        {
            midlet.serverFormViewLog();
        }
        else if (cmd == sendCommand)
        {
            String sendData = sendDataField.getString();
            Integer id = new Integer(sendMessageId++);

            for (int i=0; i < handlers.size(); i++)
            {
                ServerConnectionHandler handler =
                    (ServerConnectionHandler) handlers.elementAt(i);
                try
                {
                    handler.queueMessageForSending(
                                id,
                                sendData.getBytes());
                    statusField.setText(
                                    "Queued a send message request");
                }
                catch(IllegalArgumentException e)
                {
                    // Message length longer than
                    // ServerConnectionHandler.MAX_MESSAGE_LENGTH

                    String errorMessage =
                        "IllegalArgumentException while trying " +
                        "to send a message: " + e.getMessage();
                    handleError(handler, errorMessage);
                }
            }
        }
        else if (cmd == searchCommand)
        {
            midlet.serverFormSearchRequest(handlers.size());
        }
        else if (cmd == quitCommand)
        {
            closeAll();
            midlet.serverFormExitRequest();
        }

        // To keep this MIDlet simple, I didn't add any way
        // to drop individual connections. But you might
        // want to do so.
    }


    // ServerConnectionHandlerListener interface methods

    public void handleOpen(ServerConnectionHandler handler)
    {
        handlers.addElement(handler);
        // for the first open connection
        if (handlers.size() == 1)
        {
            removeCommand(searchCommand);

            removeCommand(sendCommand);
            addCommand(sendCommand);
        }

        // Remove the 'Add connection' command
        // when the device already has open the
        // maximum number of connections it can
        // support.
        if (handlers.size() >= maxConnections)
        {
            removeCommand(addConnectionCommand);
        }

        statusField.setText("Connection opened");
        String str = Integer.toString(handlers.size());
        numConnectionsField.setText(str);
    }


    public void handleOpenError(
                    ServerConnectionHandler handler,
                    String errorMessage)
    {
        statusField.setText("Error opening outbound connection: " +
                            errorMessage);
    }


    public void handleReceivedMessage(
                    ServerConnectionHandler handler,
                    byte[] messageBytes)
    {
        numReceivedMessages++;

        String message = new String(messageBytes);
        receivedDataField.setText(message);

        statusField.setText(
            "# messages read: " + numReceivedMessages + " " +
            "sent: " + numSentMessages);

        // Broadcast message to all clients
        for (int i=0; i < handlers.size(); i++)
        {
            ServerConnectionHandler h =
                (ServerConnectionHandler) handlers.elementAt(i);

            Integer id = new Integer(sendMessageId++);
            try
            {
                h.queueMessageForSending(id, messageBytes);
            }
            catch (IllegalArgumentException e)
            {
                String errorMessage =
                    "IllegalArgumentException while trying to " +
                    "send message: " + e.getMessage();
                handleError(handler, errorMessage);
            }
        }
    }


    public void handleQueuedMessageWasSent(
                    ServerConnectionHandler handler,
                    Integer id)
    {
        numSentMessages++;
        statusField.setText("# messages read: " +
                            numReceivedMessages + " " +
                            "sent: " + numSentMessages);
    }


    public void handleClose(ServerConnectionHandler handler)
    {
        removeHandler(handler);
        if (handlers.size() == 0)
        {
            removeCommand(sendCommand);
            addCommand(searchCommand);
        }

        // If the number of currently open connections
        // drops below the maximum number that this
        // device could have open, restore
        // 'Add connection' to the screen commands.
        if (handlers.size() < maxConnections)
        {
            removeCommand(addConnectionCommand);
            addCommand(addConnectionCommand);
        }

        statusField.setText("Connection closed");
    }


    public void handleErrorClose(ServerConnectionHandler handler,
                                 String errorMessage)
    {
        removeHandler(handler);
        if (handlers.size() == 0)
        {
            removeCommand(sendCommand);
            addCommand(searchCommand);
        }

        statusField.setText("Error (close): '" + errorMessage + "'");
    }


    public void handleError(ServerConnectionHandler handler,
                            String errorMessage)
    {
        statusField.setText("Error: '" + errorMessage + "'");
    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
看国产成人h片视频| 欧美影片第一页| 日本电影亚洲天堂一区| 精品欧美一区二区久久| 亚洲欧美日韩国产一区二区三区 | www.欧美.com| 欧美成人激情免费网| 亚洲午夜精品久久久久久久久| 国产精品91一区二区| 欧美精品777| 亚洲精品国产精华液| 成人免费视频app| 欧美精品一区二区久久婷婷| 日韩在线播放一区二区| 色婷婷综合久色| 国产精品久久久久久久久快鸭 | 中文字幕一区日韩精品欧美| 老司机精品视频一区二区三区| 在线观看日韩国产| 亚洲欧洲在线观看av| 国产福利91精品一区| 久久综合九色欧美综合狠狠| 久久精品国产99国产| 日韩一区二区三区av| 天堂一区二区在线| 欧美日韩国产影片| 亚洲大片一区二区三区| 91福利区一区二区三区| 亚洲综合久久久久| 欧美日韩综合一区| 亚洲综合成人网| 欧美色爱综合网| 丝瓜av网站精品一区二区| 中文字幕av资源一区| 国产中文字幕一区| 国产亚洲综合在线| 粉嫩av一区二区三区粉嫩| 国产精品热久久久久夜色精品三区 | 狠狠色丁香久久婷婷综合_中| 这里只有精品视频在线观看| 热久久一区二区| 精品少妇一区二区三区在线播放| 久久99精品久久久| 久久久亚洲综合| 成人精品免费网站| 亚洲靠逼com| 欧美日韩一本到| 久久99精品国产91久久来源| 久久综合久久综合九色| 国产成人精品免费| 亚洲欧美色图小说| 欧美另类久久久品| 韩国精品主播一区二区在线观看 | 91亚洲精华国产精华精华液| 亚洲综合网站在线观看| 欧美一级高清大全免费观看| 国产精品中文有码| 亚洲精品中文字幕在线观看| 91精品国产乱码久久蜜臀| 国产精品一区二区在线观看网站| 综合欧美一区二区三区| 欧美丰满美乳xxx高潮www| 国产呦萝稀缺另类资源| 亚洲天堂网中文字| 日韩欧美中文字幕制服| 成人免费的视频| 丝袜美腿一区二区三区| 国产精品视频你懂的| 538在线一区二区精品国产| 国产美女娇喘av呻吟久久| 亚洲精品视频在线| 精品免费一区二区三区| 在线视频综合导航| 国产在线观看一区二区| 亚洲综合精品久久| 欧美激情一区在线观看| 欧美精品精品一区| 不卡高清视频专区| 另类中文字幕网| 久久99精品视频| 夜夜操天天操亚洲| 国产精品免费视频一区| 91精品啪在线观看国产60岁| 99在线视频精品| 九九精品一区二区| 午夜国产不卡在线观看视频| 中文字幕av资源一区| 日韩精品中文字幕一区二区三区 | 亚洲成人第一页| 国产精品久久福利| 欧美精品一区二区高清在线观看| 欧美日韩你懂得| 一本到三区不卡视频| 成人高清在线视频| 国产一区二区电影| 久久69国产一区二区蜜臀| 亚洲一区二区综合| 国产精品亲子伦对白| 欧美精品一区二区三区蜜桃视频| 欧美嫩在线观看| 在线一区二区观看| 成人av综合一区| 国产不卡高清在线观看视频| 久久www免费人成看片高清| 亚洲国产欧美在线人成| 一区二区三区鲁丝不卡| 综合色中文字幕| 综合久久给合久久狠狠狠97色| 久久色成人在线| 久久日韩精品一区二区五区| 日韩美女视频在线| 日韩欧美精品三级| 欧美va亚洲va国产综合| 日韩欧美色电影| 欧美v日韩v国产v| 欧美videos大乳护士334| 日韩一区二区免费高清| 欧美一级国产精品| 欧美成人猛片aaaaaaa| 精品国产一区a| 精品久久久久一区二区国产| 久久亚洲精精品中文字幕早川悠里| 日韩免费在线观看| 国产午夜精品福利| 国产精品色呦呦| 一区二区三区成人| 香蕉久久一区二区不卡无毒影院| 亚洲成人免费影院| 青青国产91久久久久久| 久久99精品国产麻豆婷婷洗澡| 国产一区二区在线免费观看| 国产精品亚洲а∨天堂免在线| 丁香婷婷深情五月亚洲| 91原创在线视频| 欧美亚洲动漫精品| 欧美成人a在线| 国产精品剧情在线亚洲| 亚洲激情自拍视频| 蜜桃av一区二区三区电影| 天天操天天色综合| 韩国三级中文字幕hd久久精品| 国产成人亚洲综合a∨猫咪| av欧美精品.com| 在线播放国产精品二区一二区四区| 日韩欧美不卡一区| 国产精品乱码一区二三区小蝌蚪| 亚洲精品你懂的| 视频一区二区中文字幕| 另类综合日韩欧美亚洲| av一二三不卡影片| 91麻豆精品国产91久久久更新时间 | 欧美影院一区二区| www欧美成人18+| 亚洲一区二区在线视频| 美日韩一区二区三区| 99精品热视频| 欧美一区2区视频在线观看| 国产欧美久久久精品影院| 亚洲高清免费一级二级三级| 国产精品白丝av| 91黄色免费看| 日本一区二区成人在线| 日韩精品乱码av一区二区| 国产成人亚洲综合a∨婷婷图片| 欧美性大战久久久久久久蜜臀| 26uuu精品一区二区在线观看| 一区二区三区成人在线视频| 九九九久久久精品| 欧美日韩日日夜夜| 亚洲免费高清视频在线| 国产精品中文字幕一区二区三区| 欧美亚洲高清一区| 中文字幕在线播放不卡一区| 精品一区二区三区免费播放| 欧美亚洲自拍偷拍| 《视频一区视频二区| 国产高清成人在线| 日韩欧美国产精品一区| 性欧美大战久久久久久久久| av在线不卡电影| 国产人成亚洲第一网站在线播放| 日韩精品午夜视频| 欧美日韩免费在线视频| 亚洲你懂的在线视频| 成人免费视频视频在线观看免费 | 欧美人狂配大交3d怪物一区| 国产精品少妇自拍| 成人免费视频国产在线观看| 精品国产免费一区二区三区香蕉| 亚洲成av人片www| 欧美制服丝袜第一页| 亚洲欧美视频在线观看视频| 99热这里都是精品| 国产精品福利影院| gogo大胆日本视频一区| 中文字幕欧美激情| 高清av一区二区| 国产精品美女久久久久久久久久久| 国产河南妇女毛片精品久久久| 欧美精品一区二区在线观看|