#!/bin/sh

if [ "$1" != "stream" ]
 then
 if [ "$2" != "" ]
   then
   sh $0 stream | nc $1 $2
 else
   echo "usage: $0 host port"
   exit
 fi
else
  while true; do
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"43sdf5435syf\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"43sdf5435syf\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"hgfhw3ydgfsd\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"43sdf5435syf\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"cnhsdgas6456\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"43sdf5435syf\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"43sdf5435syf\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"hgfhw3ydgfsd\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"43sdf5435syf\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"hgfhw3ydgfsd\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"43sdf5435syf\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"hgfhw3ydgfsd\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"cnhsdgas6456\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"43sdf5435syf\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"43sdf5435syf\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"43sdf5435syf\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"43sdf5435syf\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"hgfhw3ydgfsd\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"43sdf5435syf\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"cnhsdgas6456\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"43sdf5435syf\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"43sdf5435syf\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"hgfhw3ydgfsd\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"43sdf5435syf\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"hgfhw3ydgfsd\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"43sdf5435syf\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"hgfhw3ydgfsd\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"cnhsdgas6456\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"43sdf5435syf\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"43sdf5435syf\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"hgfhw3ydgfsd\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"hgfhw3ydgfsd\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"hgfhw3ydgfsd\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"fghfgh7asdfa\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"fghfgh7asdfa\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"fghfgh7asdfa\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"cnhsdgas6456\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"fghfgh7asdfa\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"fghfgh7asdfa\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"fghfgh7asdfa\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"hgfhw3ydgfsd\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"hgfhw3ydgfsd\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"hgfhw3ydgfsd\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"fghfgh7asdfa\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"fghfgh7asdfa\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"fghfgh7asdfa\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"cnhsdgas6456\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"fghfgh7asdfa\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"fghfgh7asdfa\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"fghfgh7asdfa\"}"
    sleep 0.06
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"43sdf5435syf\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"43sdf5435syf\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"hgfhw3ydgfsd\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"43sdf5435syf\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"cnhsdgas6456\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"43sdf5435syf\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"43sdf5435syf\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"hgfhw3ydgfsd\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"43sdf5435syf\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"hgfhw3ydgfsd\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"43sdf5435syf\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"hgfhw3ydgfsd\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"cnhsdgas6456\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"43sdf5435syf\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"43sdf5435syf\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"43sdf5435syf\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"43sdf5435syf\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"hgfhw3ydgfsd\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"43sdf5435syf\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"cnhsdgas6456\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"43sdf5435syf\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"43sdf5435syf\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"hgfhw3ydgfsd\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"43sdf5435syf\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"hgfhw3ydgfsd\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"43sdf5435syf\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"hgfhw3ydgfsd\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"cnhsdgas6456\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"43sdf5435syf\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"43sdf5435syf\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"hgfhw3ydgfsd\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"hgfhw3ydgfsd\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"hgfhw3ydgfsd\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"fghfgh7asdfa\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"fghfgh7asdfa\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"fghfgh7asdfa\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"cnhsdgas6456\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"fghfgh7asdfa\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"fghfgh7asdfa\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"fghfgh7asdfa\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"hgfhw3ydgfsd\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"hgfhw3ydgfsd\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"hgfhw3ydgfsd\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"wurfhjfghfgh\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"fghfgh7asdfa\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"fghfgh7asdfa\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"fghfgh7asdfa\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"cnhsdgas6456\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"fghfgh7asdfa\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"fghfgh7asdfa\"}"
    echo "{\"_type\": \"foobar\", \"_session\": \"fghfgh7asdfa\"}"

    sleep 0.15
  done
fi