001package org.openimaj.picslurper.client; 002 003import java.io.ByteArrayInputStream; 004import java.io.IOException; 005 006import org.openimaj.io.IOUtils; 007import org.openimaj.picslurper.output.WriteableImageOutput; 008import org.zeromq.ZMQ; 009 010/** 011 * @author Sina Samangooei (ss@ecs.soton.ac.uk) 012 * 013 */ 014public class ZMQPicslurperClient { 015 /** 016 * @param args 017 */ 018 public static void main(String args[]) { 019 // Prepare our context and subscriber 020 ZMQ.Context context = ZMQ.context(1); 021 ZMQ.Socket subscriber = context.socket(ZMQ.SUB); 022 023 subscriber.connect("tcp://localhost:5563"); 024 subscriber.subscribe(new byte[0]); 025 while (true) { 026 ByteArrayInputStream stream = new ByteArrayInputStream(subscriber.recv(0)); 027 WriteableImageOutput instance; 028 try { 029 instance = IOUtils.read(stream, WriteableImageOutput.class, "UTF-8"); 030 System.out.println("Got URL: " + instance.url + " ( " + instance.stats.imageURLs + " ) "); 031 } catch (IOException e) { 032 // TODO Auto-generated catch block 033 e.printStackTrace(); 034 } 035 } 036 } 037}