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


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


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

用法

  • client.write(data)

參數

  • client (Client) 客戶端類型的任何變量
  • data (int, byte[], String) 要寫入的數據

返回

  • void

說明

將數據寫入構建客戶端時指定的服務器,或將數據寫入從服務器available()方法獲得的特定客戶端。

例子

// Creates a client that sends input to a server

import processing.net.*; 
Client myClient; 
int clicks;

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

void mouseReleased() {
  // Count the number of mouse clicks:
  clicks++;
  // Tell the server:
  myClient.write("Mouse pressed " + clicks + " times.\n");
}

void draw() { 
  // Change the background if the mouse is pressed
  if (mousePressed) {
    background(255);
  } else {
    background(0);
  }
} 

相關用法


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