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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? 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.btl2capecho;


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.btl2capecho.server.ServerConnectionHandler;
import example.btl2capecho.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 + "'");
    }
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲精品日日夜夜| 综合久久久久久| 在线看一区二区| 国产在线播放一区二区三区| 亚洲免费资源在线播放| 精品久久久影院| 在线播放亚洲一区| 色久优优欧美色久优优| 成人免费黄色在线| 国产呦精品一区二区三区网站| 亚洲国产欧美在线| 亚洲日本在线天堂| 国产精品免费av| 久久久噜噜噜久久中文字幕色伊伊| 欧美精品123区| 欧美日韩在线直播| 91电影在线观看| 成人av影院在线| 蜜臀久久99精品久久久画质超高清 | 极品美女销魂一区二区三区| 一区二区三区四区av| 亚洲免费在线视频| 国产精品三级电影| 国产色产综合产在线视频| 精品国产123| 国产亚洲综合色| 欧美极品另类videosde| 中文字幕免费观看一区| 亚洲人精品午夜| 亚洲h动漫在线| 老司机精品视频线观看86| 激情五月播播久久久精品| 国产成人一级电影| 色综合久久中文综合久久97| 欧美日韩性生活| 精品成人免费观看| 亚洲精品写真福利| 一区二区三区免费| 樱桃视频在线观看一区| 亚洲午夜精品在线| 蜜臀久久99精品久久久久久9| 麻豆精品一区二区三区| 99久久伊人精品| 欧美午夜不卡视频| 久久久久久一级片| 亚洲综合色丁香婷婷六月图片| 男女性色大片免费观看一区二区| 国内精品免费**视频| 91福利视频久久久久| 精品久久久久久综合日本欧美| 国产精品另类一区| 视频一区二区三区在线| 高清在线观看日韩| 色狠狠一区二区| 日本一区二区三区四区在线视频 | 国产亚洲欧美一级| 三级久久三级久久| 99久久精品国产导航| 日韩欧美一级二级三级久久久| 欧美一区二区视频网站| 久久精品亚洲精品国产欧美kt∨| 亚洲最大的成人av| av在线播放不卡| 国产欧美在线观看一区| 精品一区二区三区免费播放 | 日韩精品影音先锋| 奇米888四色在线精品| 欧美视频在线观看一区二区| 亚洲一区二区精品视频| 色婷婷av久久久久久久| 18涩涩午夜精品.www| 国产91精品一区二区麻豆网站| 久久综合久久鬼色中文字| 美女网站色91| 欧美成人官网二区| 国产精品99久久久久久似苏梦涵| 精品免费视频一区二区| 国产精品18久久久久久vr| 久久噜噜亚洲综合| 成人福利在线看| 亚洲视频免费看| 欧美日韩国产三级| 一个色在线综合| 色综合久久综合网| 亚洲成人av一区二区| 欧美精品在线一区二区三区| 美美哒免费高清在线观看视频一区二区| 欧美浪妇xxxx高跟鞋交| 国产精品资源网站| 亚洲激情图片一区| 精品国产在天天线2019| 成人中文字幕合集| 午夜精品福利一区二区蜜股av| 日韩一卡二卡三卡国产欧美| 国产精品一二三四五| 亚洲国产日韩综合久久精品| 欧美精品一区二区久久婷婷| 91网上在线视频| 美女尤物国产一区| 一级精品视频在线观看宜春院| 日韩欧美国产一区在线观看| 成人激情综合网站| 婷婷丁香激情综合| 亚洲三级在线观看| 久久色中文字幕| 91精品国产品国语在线不卡| av不卡免费在线观看| 日韩激情在线观看| 国产精品久久久久久久第一福利 | 亚洲免费观看视频| 精品国产免费人成在线观看| 欧美三级在线视频| 91浏览器打开| proumb性欧美在线观看| 国产在线国偷精品产拍免费yy| 天天操天天色综合| 亚洲第一久久影院| 一区二区理论电影在线观看| 亚洲婷婷在线视频| 亚洲激情综合网| 亚洲视频每日更新| 色哟哟精品一区| 欧美性一区二区| 欧美日韩亚洲高清一区二区| 欧美视频一区二区| 91麻豆精品久久久久蜜臀| 在线观看亚洲a| 欧美精品v日韩精品v韩国精品v| 91电影在线观看| 欧美裸体一区二区三区| 欧美一级精品大片| 久久久久久久久99精品| 国产精品每日更新在线播放网址| 蜜臀a∨国产成人精品| 久久精品一级爱片| 亚洲国产精品高清| 亚洲精品欧美激情| 天堂成人免费av电影一区| 强制捆绑调教一区二区| 精品中文字幕一区二区| av亚洲精华国产精华| 日本韩国精品在线| 日韩精品一区国产麻豆| 国产三级精品三级在线专区| 亚洲精品五月天| 国产乱人伦精品一区二区在线观看 | 久久成人免费日本黄色| 成人免费高清视频| 日韩视频一区二区在线观看| 中文字幕成人av| 欧美aaaaa成人免费观看视频| 成人av在线观| 精品国产凹凸成av人网站| 亚洲男人的天堂网| 精品一区二区三区香蕉蜜桃 | 欧美精品精品一区| 国产精品女人毛片| 国内精品国产成人| 91麻豆.com| 欧美激情资源网| 精品亚洲aⅴ乱码一区二区三区| 一本色道久久综合亚洲aⅴ蜜桃| 欧美xxxxxxxx| 日日夜夜一区二区| 欧洲精品一区二区| 国产精品传媒入口麻豆| 国产盗摄一区二区三区| 欧美日韩成人综合在线一区二区| 成人欧美一区二区三区1314| 国产精品一卡二卡| 久久女同精品一区二区| 看电视剧不卡顿的网站| 欧美一级生活片| 青青青伊人色综合久久| 91麻豆精品国产91久久久| 亚洲成av人片一区二区梦乃| 欧美熟乱第一页| 一区二区三区国产精华| 在线视频国内自拍亚洲视频| 亚洲自拍偷拍图区| 欧美剧情片在线观看| 日韩黄色一级片| 欧美成人vps| 国产a视频精品免费观看| 国产精品福利电影一区二区三区四区 | 欧美日韩中文字幕一区二区| 亚洲欧美精品午睡沙发| 欧日韩精品视频| 蜜桃视频在线一区| 国产日韩欧美一区二区三区乱码 | 国产成人欧美日韩在线电影| 久久精品一区蜜桃臀影院| 成人毛片在线观看| 亚洲成人动漫精品| 日韩欧美电影一区| 欧洲国产伦久久久久久久| 精品一区二区在线观看| 136国产福利精品导航| 日韩一区二区三区av| 波多野结衣中文字幕一区|