Processing oscP5 Library

孤街浪徒 提交于 2019-12-12 02:46:49

问题


I'm using the oscP5 library in Processing. I've already looked in the javadoc for oscP5 and I've browsed through the source but I can't figure it out.

When I get debug info like this: ### new Client @ netP5.TcpClient@2515

What does the value 2515 represent? I know it is not the port the client is using. Is it a unique id for the client? Is it a variable I can access in the TcpClient class?

Thanks.


回答1:


It is the objects (TcpClient) address in memory. You find the source code at src/netP5/AbstractTcpServer.java

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

This means, that your number is the String representation of TcpClient. Since nothing is implemented to return this - its the default behaviour: objects address. You can access this TcpClient object and its members as shown in to following example. I assume here for simpleness, that we look at the first object in the clients list.

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 
  }

Please note, that most of the interesting information is contained in the base object AbstractTcpClient (as shown in the example).



来源:https://stackoverflow.com/questions/5566285/processing-oscp5-library

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!