> And all socket sends are handled by client.sendProc(data: string)
    
    
    type
      Compression = enum
        uncompressed, gzip, deflate
      
      NNTPContext = object
        c: NNTP
        comp: Compression
      
      AsyncNNTPContext = object
        c: AsyncNNTP
        comp: Compression
    
    
    proc sendGzip(c: NNTP, data: string) = ...
    proc sendDeflate(c: NNTP, data: string) = ...
    proc sendRaw(c: NNTP, data: string) = ...
    
    proc send(ctx: NNTPContext, data: string) =
      switch(ctx.comp)
      case(uncompressed):
        ctx.c.sendRaw(data)
      case(gzip):
         ctx.c.sendGzip(data)
      case(deflate):
        ctx.c.sendDeflate(data)
    
    proc sendGzip(c: AsyncNNTP, data: string) = ...
    proc sendDeflate(c: AyncNNTP, data: string) = ...
    proc sendRaw(c: AsyncNNTP, data: string) = ...
    
    proc send(ctx: AsyncNNTPContext, data: string) =
      switch(ctx.comp)
      case(uncompressed):
        ctx.c.sendRaw(data)
      case(gzip):
         ctx.c.sendGzip(data)
      case(deflate):
        ctx.c.sendDeflate(data)
    
    
    
    
    Run

Reply via email to