处理oscP5库

时间:2011-04-06 12:24:26

标签: processing osc

我在Processing中使用oscP5库。我已经查看了用于oscP5的javadoc,我浏览了源代码,但我无法弄明白。

当我得到这样的调试信息时: ### new Client @ netP5.TcpClient@2515

2515 的值代表什么?我知道它是客户端正在使用的端口。它是客户的唯一ID吗?它是我可以在TcpClient类中访问的变量吗?

感谢。

1 个答案:

答案 0 :(得分:1)

它是内存中的对象(TcpClient)地址。你找到源代码 SRC / netP5 / AbstractTcpServer.java

TcpClient t = new TcpClient(this, _myServerSocket.accept(),
                           _myTcpPacketListener, _myPort, _myMode);
if (NetP5.DEBUG) {
  System.out.println("### new Client @ " + t);
}

这意味着,您的数字是TcpClient的字符串表示形式。由于没有实现任何返回它 - 它的默认行为:对象地址。您可以访问此TcpClient对象及其成员,如以下示例所示。我假设这里简单,我们会查看客户列表中的第一个对象。

if (oscP5tcpServer.tcpServer().getClients().length>0) {
    TcpClient tcpClient = (TcpClient)oscP5tcpServer.tcpServer().getClient(0);
    print (tcpClient);                // address - same as your printed output
    print (tcpClient.netAddress());   // string with "ip:port"
    print (tcpClient.socket());       // Socket object 
  }

请注意,大多数有趣的信息都包含在基础对象AbstractTcpClient中(如示例所示)。