... | ... | @@ -168,3 +168,38 @@ try { |
|
|
catch (InterruptedException e) {
|
|
|
}
|
|
|
```
|
|
|
|
|
|
And the Python example:
|
|
|
```python
|
|
|
import threading
|
|
|
|
|
|
# Define the function retrieving the output.
|
|
|
def printOutput(socket):
|
|
|
while True:
|
|
|
output = socket.receive()
|
|
|
if output:
|
|
|
print(output.getMessage())
|
|
|
else:
|
|
|
return
|
|
|
|
|
|
# Start the app with the OUTPUTSTREAM option.
|
|
|
app = server.start("streampy", cameopy.OUTPUTSTREAM)
|
|
|
|
|
|
# Get the outputstream socket.
|
|
|
socket = app.getOutputStreamSocket()
|
|
|
|
|
|
# Start the thread.
|
|
|
t = threading.Thread(target=printOutput, args=(socket,))
|
|
|
t.start()
|
|
|
|
|
|
# Wait for 1s.
|
|
|
time.sleep(1)
|
|
|
|
|
|
# Stop the output stream socket.
|
|
|
socket.cancel()
|
|
|
|
|
|
# Wait for the end of the thread.
|
|
|
t.join()
|
|
|
```
|
|
|
|
|
|
Retrieving the output may not be only restricted to debug. If you need to integrate an external program that only has output, control could be done by analyzing the output stream. |
|
|
\ No newline at end of file |