Changeset 6646

Show
Ignore:
Timestamp:
06/18/09 17:15:31 (15 months ago)
Author:
metamorph68
Message:

Backported new parameter for on_connect handlers in input.harbor

Location:
branches/bugfix-0.9.1
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • branches/bugfix-0.9.1/CHANGES

    r6645 r6646  
    1212 - Get a node's striping status when stripping 
    1313   blank with strip_blank (#260). 
     14 - on_connect function for input.harbor now receives the 
     15   list of headers given by the connected source (#266). 
    1416 
    15170.9.0 (01-03-2009) 
  • branches/bugfix-0.9.1/src/sources/harbor_input.ml

    r6644 r6646  
    166166    if relaying then self#disconnect 
    167167 
    168   method relay socket = 
     168  method relay (headers:(string*string) list) socket = 
    169169    relaying <- true ; 
    170     on_connect () ; 
     170    let headers = List.map (fun (x,y) -> String.lowercase x,y) headers in 
     171    on_connect headers ; 
    171172    begin match dumpfile with 
    172173      | Some f -> 
     
    218219        Some "Maximum duration of the buffered data."; 
    219220 
    220         "on_connect", Lang.fun_t [] Lang.unit_t, 
    221         Some (Lang.val_cst_fun [] Lang.unit), 
    222         Some "Functions to excecute when a source is connected"; 
     221        "on_connect", Lang.fun_t  
     222        [false,"",Lang.list_t (Lang.product_t Lang.string_t Lang.string_t)] Lang.unit_t, 
     223        Some (Lang.val_cst_fun  
     224          ["","headers",None] Lang.unit), 
     225        Some "Function to execute when a source is connected. \ 
     226              Its receives the list of headers, of the form: \ 
     227              (\"label\",\"value\"). All labels are lowercase."; 
    223228 
    224229        "on_disconnect",Lang.fun_t [] Lang.unit_t, 
     
    309314         let bufferize = Lang.to_float (List.assoc "buffer" p) in 
    310315         let max = Lang.to_float (List.assoc "max" p) in 
    311          let on_connect () = 
    312            ignore (Lang.apply (List.assoc "on_connect" p) []) 
     316         let on_connect l = 
     317           let l =  
     318             List.map  
     319              (fun (x,y) -> Lang.product (Lang.string x) (Lang.string y)) 
     320              l 
     321           in 
     322           let arg = Lang.list l in 
     323           ignore (Lang.apply (List.assoc "on_connect" p) ["",arg]) 
    313324         in 
    314325         let on_disconnect = fun () -> ignore (Lang.apply