Commit graph

3 commits

Author SHA1 Message Date
Xiongfei Guo
02ca593347 Support delete a fd event.
When you call the fd_add, it will return an object with `delete` method.
So you can delete that event if you want.

Signed-off-by: Xiongfei(Alex) Guo <xfguo@credosemi.com>
2014-06-24 14:30:30 +01:00
Xiongfei Guo
79b56268b4 Added fd_add method for uloop lua binding.
Use uloop.fd_add like this:

    local socket = require "socket"

    udp = socket.udp()

    uloop.fd_add(
        udp, -- socket
        function( -- callback function
            ufd,    -- socket object when register the fd
            events  -- uloop events. eg. uloop.ULOOP_READ .
        )
            local words, msg_or_ip, port_or_nil = ufd:receivefrom()
            print('Recv UDP packet from '..msg_or_ip..':'..port_or_nil..' : '..words)
        end,
        uloop.ULOOP_READ -- event you want to listen
    )

The `examples/uloop-example.lua` show an example of this work.

Signed-off-by: Xiongfei(Alex) Guo <xfguo@credosemi.com>
2014-06-24 14:30:30 +01:00
Felix Fietkau
0a81131257 add an example script for the uloop lua binding 2012-09-27 13:47:46 +02:00