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

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

?? bttalker.java

?? 這是一個(gè)Micro3D的學(xué)習(xí)代碼
?? JAVA
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
/*****************************************************************************
 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;

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久蜜臀中文字幕| 久久成人免费网| 亚欧色一区w666天堂| 久久66热re国产| 在线日韩av片| 国产日本一区二区| 蜜桃91丨九色丨蝌蚪91桃色| 国产成人自拍网| 欧美美女黄视频| 亚洲视频在线一区二区| 精品亚洲免费视频| 在线成人高清不卡| 亚洲天堂成人网| 国产成人免费网站| 国产最新精品精品你懂的| 欧美伊人精品成人久久综合97| 久久久www成人免费无遮挡大片| 亚洲无线码一区二区三区| 97精品久久久午夜一区二区三区 | 日韩免费成人网| 一区二区免费看| 亚洲第四色夜色| 欧美色男人天堂| 555www色欧美视频| 午夜精品久久久久影视| 91视频com| 亚洲视频每日更新| 色婷婷综合久色| 亚洲色图欧美激情| 91免费小视频| 亚洲激情图片qvod| 欧美日韩三级一区二区| 人人狠狠综合久久亚洲| 亚洲国产成人tv| 欧美人xxxx| 美国毛片一区二区| 欧美成人三级电影在线| 极品少妇xxxx精品少妇偷拍| 狠狠色丁香久久婷婷综合_中 | 亚洲综合免费观看高清完整版在线| 成人看片黄a免费看在线| 国产拍欧美日韩视频二区| 国产乱国产乱300精品| 国产午夜久久久久| 高清成人在线观看| 国产老肥熟一区二区三区| 成人综合在线观看| 一区二区在线观看免费| 色婷婷精品大在线视频| 天堂成人国产精品一区| 日韩欧美高清在线| 韩国一区二区三区| 亚洲视频狠狠干| 欧美精品粉嫩高潮一区二区| 国产网站一区二区三区| 色哟哟国产精品免费观看| 性做久久久久久免费观看| 精品毛片乱码1区2区3区| 高清成人免费视频| 亚洲最大成人综合| 91精品国产品国语在线不卡| 国产一区二区视频在线播放| 1区2区3区国产精品| 亚洲自拍与偷拍| 精品三级在线观看| 91免费版在线看| 亚洲国产中文字幕| 欧美婷婷六月丁香综合色| 久久福利资源站| 亚洲六月丁香色婷婷综合久久 | 精品国产乱码久久久久久免费 | 天天综合天天综合色| 337p粉嫩大胆噜噜噜噜噜91av| 成人久久视频在线观看| 日韩精品电影一区亚洲| 日本一区二区视频在线| 视频一区二区国产| 亚洲欧洲成人精品av97| 日韩精品一区二区三区swag| 色哟哟一区二区| 国产成人在线电影| 另类小说综合欧美亚洲| 夜夜亚洲天天久久| 国产调教视频一区| 欧美一级欧美三级在线观看| 色综合天天综合在线视频| 狠狠色狠狠色综合系列| 日韩精品欧美精品| 日本精品一区二区三区高清 | 日本道精品一区二区三区| 麻豆久久一区二区| 亚洲夂夂婷婷色拍ww47| 国产精品美女久久久久久| 日韩精品在线看片z| 欧美在线视频不卡| 欧美美女喷水视频| 一本到高清视频免费精品| 欧美日韩一区二区三区免费看| 一区二区日韩电影| 亚洲欧洲成人av每日更新| 色综合久久天天综合网| 成人激情黄色小说| 激情小说欧美图片| 免费观看在线色综合| 午夜精品久久一牛影视| 日韩成人午夜精品| 欧美精品第1页| 欧美日韩国产综合草草| 欧美亚日韩国产aⅴ精品中极品| a级高清视频欧美日韩| 国产91精品在线观看| 国产在线精品一区二区夜色| 久久超碰97中文字幕| 奇米影视在线99精品| 秋霞av亚洲一区二区三| 天堂成人免费av电影一区| 日韩二区三区四区| 青青草91视频| 国产乱码字幕精品高清av| 国产一区二区看久久| 国产成人精品影视| 成人激情动漫在线观看| 99精品视频在线观看免费| 91麻豆免费看| 亚洲已满18点击进入久久| 亚洲一区二区三区在线播放| 亚洲成av人片观看| 日本人妖一区二区| 国产麻豆午夜三级精品| 成人av集中营| 欧洲一区在线电影| 91精品国产综合久久久蜜臀粉嫩| 精品99999| 中文字幕 久热精品 视频在线| 综合激情成人伊人| 亚洲激情综合网| 视频精品一区二区| 国产一区二区三区在线观看精品| 国产河南妇女毛片精品久久久| 99久久精品免费| 欧美日韩视频第一区| 久久久五月婷婷| 亚洲天堂免费在线观看视频| 丝袜美腿一区二区三区| 国产精品一区在线| 在线这里只有精品| 精品国产免费人成电影在线观看四季| 久久精品夜色噜噜亚洲aⅴ| 日韩理论片一区二区| 视频在线在亚洲| 成人精品免费网站| 91精品国产免费久久综合| 国产欧美日韩激情| 91精品国产色综合久久久蜜香臀| 久久久久久99久久久精品网站| 亚洲天堂中文字幕| 国产一区在线视频| 欧亚一区二区三区| 26uuu国产一区二区三区| 一区二区免费在线播放| 福利电影一区二区三区| 欧美一区二区三区免费在线看| 国产精品污www在线观看| 亚洲午夜精品网| 成人免费看黄yyy456| 91.com视频| 一区二区成人在线观看| 国产精品77777竹菊影视小说| 欧美三级中文字| 亚洲欧洲国产日本综合| 黑人巨大精品欧美一区| 欧美精品自拍偷拍| 一区二区在线观看视频在线观看| 国产在线精品一区二区三区不卡| 在线中文字幕一区二区| 国产精品毛片大码女人| 看片网站欧美日韩| 欧美精品第1页| 亚洲国产精品久久久久秋霞影院| 91热门视频在线观看| 中文天堂在线一区| 一色桃子久久精品亚洲| 国内成+人亚洲+欧美+综合在线| 欧美片网站yy| 亚洲欧美精品午睡沙发| k8久久久一区二区三区 | 久久精品国产亚洲高清剧情介绍 | 久久精品夜色噜噜亚洲aⅴ| 蜜臀久久久久久久| 欧美喷水一区二区| 亚洲mv在线观看| 亚洲综合无码一区二区| 成人毛片在线观看| 欧美国产一区二区| 国产综合久久久久久久久久久久| 91精品国产综合久久精品麻豆| 亚洲一区电影777| 欧美网站大全在线观看| 亚洲一本大道在线| 欧美日韩一本到|