當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Processing Client.active()用法及代碼示例

Processing, 類Client中的active()用法介紹。

用法

  • client.active()

參數

  • client (Client) 客戶端類型的任何變量

返回

  • boolean

說明

如果此客戶端仍然處於活動狀態並且沒有遇到任何問題,則返回 true

例子

import processing.net.*; 

Client myClient; 
int dataIn; 

void setup() { 
  size(200, 200); 
  // Connect to the local machine at port 5204.
  // This example will not run if you haven't
  // previously started a server on this port.
  myClient = new Client(this, "127.0.0.1", 5204);
} 

void draw() { 
  if (myClient.active() == true) {
    if (myClient.available() > 0) { 
      dataIn = myClient.read();
    }
  } else {
    println("Client is not active."); 
  }
  background(dataIn);
} 

void mousePressed() {
  myClient.stop(); 
}

相關用法


注:本文由純淨天空篩選整理自processing.org大神的英文原創作品 Client.active()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。