与加工应用Adobe AIR的桌面应用程序进行通信 [英] Adobe AIR desktop application communicate with Processing application
问题描述
我有一个处理应用程序,它必须跟一个桌面Adobe AIR应用程序。 任何人都可以建议最好的选择需要考虑以下?
I have a Processing application that must talk to a desktop Adobe AIR application. Can anyone suggest the best options considering the following?
如果插座的答案,这类型的Socket,UDP(数据报班),ServerSocket的,或者只是简单的Socket?
If sockets are the answer, which type of Socket, UDP(Datagram Class), ServerSocket or just plain Socket?
这两种都是应用程序驻留在同一机 -
-latency重要的,更小更好的
-signals发送小,由3个值
-both apps reside on same machine
-latency important, smaller better
-signals being sent are small, consisting of 3 values
- 通讯只有1路,处理到Adobe AIR
-communication is 1 way only, processing TO Adobe AIR
推荐答案
在加工方面,你可以使用 oscP5 :
On the Processing side you can use oscP5:
import oscP5.*;
import netP5.*;
OscP5 osc;
NetAddress where;
void setup() {
frameRate(25);text("click to send\nOSC",5,50);
osc = new OscP5(this,12000);
where = new NetAddress("127.0.0.1",8082);
}
void draw() {}
void mousePressed() {
OscMessage what = new OscMessage("/straps");
what.add(193.4509887695313);
osc.send(what, where);
}
在AIR你可以使用一个<一个href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/DatagramSocket.html"相对=nofollow> DatagramSocket的确实如此。幸运的是,你可以使用一些具有类似的 TUIO AS3的UDPConnector 。这是一个基本的AS3示例:
In AIR you would use a DatagramSocket indeed. Luckily you can use something that with OSC packets like TUIO AS3's UDPConnector. Here's a basic as3 sample:
package
{
import flash.display.Sprite;
import flash.utils.getDefinitionByName;
import org.tuio.connectors.UDPConnector;
import org.tuio.osc.*;
public class BasicOSC extends Sprite implements IOSCConnectorListener
{
private var oscSocket:UDPConnector;
private const OSCSERVER:String = "127.0.0.1";
private const PORT:int = 8082;
public function BasicOSC()
{
try{
oscSocket = new UDPConnector(OSCSERVER,PORT);
oscSocket.addListener(this);
trace(this,"OSC ready");
}catch(e:Error){ trace(e.getStackTrace()); }
}
public function acceptOSCPacket(oscPacket:OSCPacket):void{
//handle OSC here
var message:OSCMessage = oscPacket as OSCMessage;
trace("message from :",message.address,"at",new Date());
for(var i:int = 0; i < message.arguments.length; i++)
trace("\targs["+i+"]",message.arguments[i]);
}
}
}
这是大概是我用过一段这些项目中的:
This is roughly what I used for some of these projects:
这篇关于与加工应用Adobe AIR的桌面应用程序进行通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!