AltME: R3 Protocols

Messages

GrahamC
No new tutorial yet .. there was an attempt to expand it .. but that has stagnated
always a problem with committee approach lol
Rebolek
Hm, the simple example works, but trying to put it in scheme does nothing yet...
GrahamC
is your redis:// on github yet?
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 ?

Last message posted 486 weeks ago.