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

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

?? bttalker.java

?? 這是一個Micro3D的學習代碼
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/*****************************************************************************
 COPYRIGHT All rights reserved Sony Ericsson Mobile Communications AB 2005.

 The software is the copyrighted work of Sony Ericsson Mobile Communications AB.
 The use of the software is subject to the terms of the end-user license
 agreement which accompanies or is included with the software. The software is
 provided "as is" and Sony Ericsson specifically disclaim any warranty or
 condition whatsoever regarding merchantability or fitness for a specific
 purpose, title or non-infringement. No warranty of any kind is made in
 relation to the condition, suitability, availability, accuracy, reliability,
 merchantability and/or non-infringement of the software provided herein.
 *****************************************************************************/

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.bluetooth.*;
import java.io.IOException;
import java.util.*;
import com.mascotcapsule.micro3d.v3.Vector3D;

/*
 * After conection is established, this class handles actual 
 * sending and receiving of information.
 * Messages always starts with a "command type".
 * Handling of received messages is based on a type of the "command".
*/
public class BTTalker
{
  BTTalkerObserver observer;
  private L2CAPConnection conn;

  private static byte BTCMD_SAY_HELLO            = 0x01;
  private static byte BTCMD_UPDATE_SPEED_AND_POS = 0x02;
  private static byte BTCMD_START_3D_WORLD       = 0x03;
  private static byte BTCMD_READY_FOR_PLAY       = 0x04;
  private static byte BTCMD_COLISION_SIGNAL      = 0x05;
  private static byte BTCMD_COLISION_CONFIRM     = 0x06;
  private static byte BTCMD_COLISION_NONE        = 0x07;

  private boolean receivingStarted = false;
  private boolean appIsServer = true;

  // Receive processing
  private Vector receiveDataStack = new Vector();
  private byte receiveBuf[] = null;
  private int receiveIndex = 0;

  // Transmit processing
  private Vector sendDataStack = new Vector();
  private byte transmitBuffer[];
  private int transmitIndex = 0;

  private static boolean amIReady    = false;
  private static boolean avatarReady = false;

  private BtReceiveThread mBtReceiver;
  private BtReaderThread mBtReader;

///////////////////////////////////////////////////////////////////////////////
//                                                                           //
//                             FUNCTIONS                                     //
//                                                                           //
///////////////////////////////////////////////////////////////////////////////

  public BTTalker( BTTalkerObserver aObserver,
                   L2CAPConnection aConn,
                   boolean aAppIsServer )
  {
    this.observer = aObserver;
    this.conn = aConn;
    this.appIsServer = aAppIsServer;

    try {
      // buffer with maximum number of bytes that can be sent in a single send()
      transmitBuffer = new byte[conn.getTransmitMTU()];
      transmitIndex = 2;  // reserve first 2 bytes for length of payload

      // thread for receiving data from other party
      mBtReceiver = new BtReceiveThread();
      mBtReceiver.start();
      // thread for reading (and proccessing) of received data
      mBtReader = new BtReaderThread();
      mBtReader.start();
    }
    catch (Exception e) {
      System.out.println("ERROR: BTTalker::BTTalker()" + e);
    }
  }

  // this class is used to start receiving data from BT connection
  class BtReceiveThread extends Thread
  {
    public void run()
    {
      startAndDoReceive();
    }
  }

  // this function receives data from BT connection
  void startAndDoReceive()
  {
    if( receivingStarted == true )
      return;

    receivingStarted = true;

    try {
      System.out.println("Starting Server");
      byte[] data = null;
      int length;
      // get maximum number of bytes that can be read in a single receive()
      length = conn.getReceiveMTU();
      data = new byte[length];
      length = conn.receive(data);
      // receiving of information from other party is performed in this loop
      while (length != -1)
      {
        receiveData(data, length);
        try {
          length = conn.receive(data);
        }
        catch (IOException e) {
          System.out.println("ETalk01 err: reading: " + e);
          break;
        }
      }
      data = null;
    }
    catch(Exception e) {
      System.out.println("ETalk02 err: " + e);
    }
    finally {
      System.out.println("Close receiving");
      observer.setDisconnected();
    }   
  }

  // class that is used to start reading information from data received over BT
  class BtReaderThread extends Thread
  {
    public void run() {
      handleReadData();
    }
  }

  // read (and proccess) data received from BT connection
  private void handleReadData()
  {
    byte b;
    while(true)
    {
      b = read();
      if( b == BTCMD_UPDATE_SPEED_AND_POS ||
          b == BTCMD_COLISION_SIGNAL ||
          b == BTCMD_COLISION_NONE )
      {
        int x = 0, y = 0, angY = 0, vX = 0, vY = 0;
        int e, f, g, h;
        boolean isNegative;
        for( int i=0; i<5; ++i )
        {
          isNegative = false;
          e = (int)read();
          f = (int)read();
          g = (int)read();
          h = (int)read();
          if( e == -1 ) {
            isNegative = true;
            if( f < 0 ) f = 256 + f;
            if( g < 0 ) g = 256 + g;
            if( h < 0 ) h = 256 + h;
          }
          e = (e << 24);
          f = (f << 16);
          g = (g << 8);
          if( !isNegative ) {
            if( e < 0 ) e = 256 + e;
            if( f < 0 ) f = 256 + f;
            if( g < 0 ) g = 256 + g;
            if( h < 0 ) h = 256 + h;
          }
          switch(i) {
            case 0 : x    = e+f+g+h; break;
            case 1 : y    = e+f+g+h; break;
            case 2 : angY = e+f+g+h; break;
            case 3 : vX   = e+f+g+h; break;
            case 4 : vY   = e+f+g+h; break;
          }
        }
        if( b == BTCMD_UPDATE_SPEED_AND_POS )
          observer.updateAvatarValues(x, y, angY, vX, vY);
        else if( b == BTCMD_COLISION_SIGNAL )
          observer.updateOnColisionSignal(x, y, angY, vX, vY);
        else if ( b == BTCMD_COLISION_NONE )
        {
          Vector3D awPos   = new Vector3D(x, y, 0);
          Vector3D awSpeed = new Vector3D(vX, vY, 0);
          observer.colisionNone(awPos, angY, awSpeed);
        }
      }
      else if( b == BTCMD_COLISION_CONFIRM )
      {
        Vector3D awPos    = new Vector3D(0, 0, 0);
        Vector3D awSpeed  = new Vector3D(0, 0, 0);
        Vector3D carSpeed = new Vector3D(0, 0, 0);
        int angY = 0;
        int e, f, g, h;
        boolean isNegative;
        for( int i=0; i<7; ++i )
        {
          isNegative = false;
          e = (int)read();
          f = (int)read();
          g = (int)read();
          h = (int)read();
          if( e == -1 ) {
            isNegative = true;
            if( f < 0 ) f = 256 + f;
            if( g < 0 ) g = 256 + g;
            if( h < 0 ) h = 256 + h;
          }
          e = (e << 24);
          f = (f << 16);
          g = (g << 8);
          if( !isNegative ) {
            if( e < 0 ) e = 256 + e;
            if( f < 0 ) f = 256 + f;
            if( g < 0 ) g = 256 + g;
            if( h < 0 ) h = 256 + h;
          }
          switch(i) {
            case 0 : awPos.x    = e+f+g+h; break;
            case 1 : awPos.y    = e+f+g+h; break;
            case 2 : angY       = e+f+g+h; break;
            case 3 : awSpeed.x  = e+f+g+h; break;
            case 4 : awSpeed.y  = e+f+g+h; break;
            case 5 : carSpeed.x = e+f+g+h; break;
            case 6 : carSpeed.y = e+f+g+h; break;
          }
        }
        observer.colisionConfirmed(awPos, angY, awSpeed, carSpeed);
      }
      else if (b == BTCMD_SAY_HELLO) {
        observer.updateString("Received: Hello message");
        // if received hello message -> conection is working properly and
        // our 3D world can be started. Tell client to create itself
        if(appIsServer) {
          remoteStart3DWorld();
          observer.startWorking3D(false);
        }
      }
      else if (b == BTCMD_START_3D_WORLD) {
        // only client is able to receive this message
        observer.updateString("Received: start 3D world");
        if( !appIsServer )
          observer.startWorking3D(false);
      }
      else if (b == BTCMD_READY_FOR_PLAY) {
        System.out.println("Received: avatar ready");
        avatarReady = true;
        if(amIReady)
          observer.startMultiRace();
      }
      else {
        System.out.println("Flag corrupted received: " + (int) b);
      }
    }
  }

  // Process data received from BT.
  public void receiveData(byte buf[], int length)
  {
    if (length <= 2) {
      System.out.println("Dropped len=" + length);
      return;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产午夜亚洲精品不卡| 肉肉av福利一精品导航| 亚洲一卡二卡三卡四卡 | 成人小视频在线| 欧美三级中文字幕在线观看| 久久九九久久九九| 午夜欧美大尺度福利影院在线看| 国产在线播精品第三| 欧美日韩视频在线一区二区| 国产亚洲午夜高清国产拍精品| 亚洲va韩国va欧美va精品| 国产裸体歌舞团一区二区| 91精彩视频在线观看| 欧美国产综合一区二区| 日韩高清不卡在线| 欧美色图一区二区三区| 国产精品欧美久久久久无广告| 免费欧美在线视频| 欧美日韩一区二区三区免费看 | 国产精品77777| 欧美一级欧美三级在线观看 | 久久九九久精品国产免费直播| 亚洲第一主播视频| 一本大道综合伊人精品热热 | 亚洲精品一区二区在线观看| 亚洲成av人片在线观看| 国产精品资源站在线| 亚洲精品你懂的| 国产精品成人一区二区艾草| 一区二区三区日韩欧美精品| 国产乱人伦偷精品视频免下载| 91麻豆精品国产91久久久久久| 亚洲精品一卡二卡| 色综合天天狠狠| 亚洲男女一区二区三区| 91精品91久久久中77777| 亚洲特级片在线| www.性欧美| 亚洲精品国产精华液| 99久久99久久久精品齐齐| 亚洲视频香蕉人妖| 欧美三级中文字幕在线观看| 亚洲国产精品久久久久秋霞影院 | 欧美电影免费观看高清完整版在线观看| 亚洲最色的网站| 欧美日韩精品一区二区天天拍小说| 亚洲精品国产成人久久av盗摄| 色婷婷综合久久久久中文| 亚洲精品久久嫩草网站秘色| 欧洲激情一区二区| 日韩专区中文字幕一区二区| 欧美变态凌虐bdsm| 国产成人免费视频一区| 中文字幕一区在线观看视频| 色婷婷av一区二区三区大白胸| 一区二区久久久| 欧美一区二区三区四区视频| 久久国产精品99久久久久久老狼 | 国产精品乱人伦中文| 91香蕉视频黄| 亚洲18色成人| 337p粉嫩大胆噜噜噜噜噜91av| 成人精品国产一区二区4080| 亚洲免费观看高清完整版在线观看 | 国产欧美日韩综合| 91色在线porny| 日韩av一区二区三区| 国产婷婷色一区二区三区| 一本大道久久a久久综合婷婷| 亚洲午夜精品17c| 国产亚洲欧美激情| 欧美影院精品一区| 国产在线看一区| 亚洲一区二区三区四区中文字幕| 日韩午夜av电影| 91最新地址在线播放| 蜜桃视频在线一区| 亚洲人妖av一区二区| 日韩欧美亚洲国产精品字幕久久久| 国产成人一区在线| 日日摸夜夜添夜夜添亚洲女人| 久久女同互慰一区二区三区| 色哟哟一区二区三区| 国产伦精品一区二区三区在线观看 | 五月天久久比比资源色| 日本一区二区免费在线观看视频| 欧美日韩国产经典色站一区二区三区| 国产精品 日产精品 欧美精品| 亚洲第一福利一区| 一区免费观看视频| 久久免费的精品国产v∧| 在线观看国产日韩| 不卡欧美aaaaa| 久久精品国产一区二区三| 亚洲精品国产a| 中文字幕永久在线不卡| 久久久久久久综合狠狠综合| 欧美高清视频www夜色资源网| 成人v精品蜜桃久久一区| 久久国产精品99精品国产 | 欧美老人xxxx18| 99久久精品国产毛片| 国产一区二区三区久久悠悠色av| 亚洲一区二区不卡免费| 成人免费一区二区三区视频| 久久综合九色综合久久久精品综合 | 在线视频你懂得一区二区三区| 国产福利精品导航| 激情综合色播激情啊| 蜜桃在线一区二区三区| 美女一区二区三区在线观看| 三级不卡在线观看| 日韩一区精品字幕| 日韩国产精品久久| 麻豆一区二区三| 男女男精品视频网| 麻豆精品久久久| 精彩视频一区二区| 国产在线精品一区二区夜色| 精品一区二区精品| 国产成人精品网址| 国产成人免费xxxxxxxx| 国产精品亚洲人在线观看| 国产精品亚洲第一| av亚洲精华国产精华精华 | 国产精品色在线观看| 国产视频亚洲色图| 欧美国产日韩在线观看| 国产精品欧美久久久久一区二区| 中文字幕免费一区| 亚洲欧美日韩系列| 性久久久久久久| 老司机精品视频在线| 精品中文字幕一区二区小辣椒| 黄页网站大全一区二区| 国产成人自拍网| 色悠久久久久综合欧美99| 欧美三级中文字| 日韩欧美一卡二卡| 亚洲国产精品精华液ab| 亚洲蜜臀av乱码久久精品蜜桃| 亚洲激情av在线| 日韩电影在线观看一区| 黑人精品欧美一区二区蜜桃| 懂色av一区二区夜夜嗨| 色综合一个色综合| 欧美精品少妇一区二区三区| 久久综合中文字幕| 亚洲人成小说网站色在线| 日韩av网站免费在线| 国产福利一区二区| 欧美日韩一级二级三级| 26uuu亚洲综合色| 一级做a爱片久久| 国模无码大尺度一区二区三区| 成人黄动漫网站免费app| 欧美日韩中文字幕一区| 26uuu久久天堂性欧美| 亚洲视频资源在线| 麻豆成人久久精品二区三区小说| 成人妖精视频yjsp地址| 91麻豆精品国产91| 一区免费观看视频| 久久精品国产**网站演员| 91亚洲精品乱码久久久久久蜜桃| 777亚洲妇女| 一区二区三区免费看视频| 国产麻豆成人精品| 欧美色欧美亚洲另类二区| 国产欧美一区二区精品性| 日韩av电影一区| 91美女蜜桃在线| 日本一区二区三区国色天香| 日韩和欧美的一区| 色哟哟日韩精品| 国产精品对白交换视频| 另类小说综合欧美亚洲| 欧美三级电影网| 亚洲精品视频观看| 丰满少妇在线播放bd日韩电影| 欧美一区二区视频在线观看2022 | 91精品办公室少妇高潮对白| 亚洲精品在线电影| 免费的成人av| 欧美日韩激情在线| 亚洲美女屁股眼交3| 成人av免费在线观看| 久久久久国产精品麻豆ai换脸| 六月丁香综合在线视频| 欧美日韩小视频| 亚洲午夜精品一区二区三区他趣| 国产99精品视频| 久久久久国产精品人| 精品在线一区二区三区| 欧美一区二区视频网站| 日韩专区欧美专区| 91精品国产品国语在线不卡| 天天做天天摸天天爽国产一区| 欧美羞羞免费网站| 亚洲国产视频在线|