 s = null
 
 crypto = require 'crypto'
+rj = require 'random-json'
+
+##=======================================================================
 
 class P_v1 extends server.Handler
   h_reflect : (arg, res) -> res.result arg
+
+##=======================================================================
 
 exports.init = (cb) ->
   


  cb()


exports.destroy = (cb) ->
  await s.close defer()

  await s.listen defer err
  cb err

##=======================================================================

exports.volley_of_strings = (T, cb) ->
  n = 100
  genfn = (rcb) ->
    sz = 10000
    await crypto.randomBytes sz, defer ex, buf
    rcb { r : buf.toString 'base64' }
  
  await run_test n, T, genfn, defer()
  cb()
    
##=======================================================================

exports.volley_of_objects = (T, cb) ->
  n = 400
  genfn = (rcb) ->
    await rj.obj defer obj
    rcb obj
  await run_test n, T, genfn, defer()
  cb()

##=======================================================================

run_test = (n, T, obj_gen, cb) ->

  await T.connect PORT, "P.1", defer x, c
  
