AltME: R3 Protocols

Messages

Rebolek
Yes, but not the async part yet.
GrahamC
want to give us the gist ?
Rebolek
I use this for testing the async version:
do %prot-redis.r3
async-handler: func [event /local port] [
    port: event/port
    print ["==TCP-event:" event/type]
    ;print ["Awake-event:" event/type]
    switch/default event/type [
        lookup [open event/port]
        connect [
;           send-redis-request event/port
            write event/port event/port/locals
        ]
        wrote [read event/port]
        read  [
            print ["Read" length? event/port/data "bytes"]
            return true
        ]
        close [
            event/port/spec/port-state: 'closed
            return true
        ]
    ] [
        print ["Unexpected event:" event/type]
        close event/port
        return true
    ]
    false ; returned
]
rs: redis://192.168.211.10
rp: make port! rs
rp/awake: :async-handler
open rp
write rp [SET asynctest true]
probe wait [rp 3]
GrahamC
is the link, this tcp-port/spec/port-state: 'ready should be 'closed or something but that's not the issue
connect [
;           send-redis-request event/port
            write event/port event/port/locals
        ]
Doing two consecutive writes?
Rebolek
No, the first one is commented.
GrahamC
oh ...
Rebolek
It's bit messy...
GrahamC
yeah ..
you have
port: event/port
but then still do write event/port
Rebolek
yes, but it shouldn't be problem, no? It's copypasted from two different versions...
GrahamC
It looks good to me .. but I only just woke up
Rebolek
It prints "Read 5 bytes" and then waits until timeout. [Return true] is there so I guess it should work. But it doesn't :/
GrahamC
why are you not using the port returned by 'open?
Rebolek
you mean like [rp: open rp]  ?
I copied that code from the example on rebol.net
GrahamC
you return the newly opened port .. so I thought you'd use it ?
Andreas
Bolek, you don't install an awake handler on the TCP subport.
In line 400, you explicitly clear the awake handler on the TCP subport:
https://github.com/rebolek/prot-redis/blob/master/prot-redis.r3#L400
So I don't think the awake handler you install on the Redis parent port (the example you pasted above) will be called at all.
GrahamC
so, you need to get the port returned by open and install the async handler on that

Last message posted 489 weeks ago.