AltME: R3 Protocols
Messages
Wednesday 5th June, 2013
GrahamC
20:53
No new tutorial yet .. there was an attempt to expand it .. but that has stagnated
20:54
always a problem with committee approach lol
Rebolek
20:59
Hm, the simple example works, but trying to put it in scheme does nothing yet...
GrahamC
21:02
is your redis:// on github yet?
Rebolek
21:02
Yes, but not the async part yet.
GrahamC
21:03
want to give us the gist ?
Rebolek
21:03
https://github.com/rebolek/prot-redis
21:07
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
21:08
is the link, this tcp-port/spec/port-state: 'ready should be 'closed or something but that's not the issue
21:10
connect [
; send-redis-request event/port
write event/port event/port/locals
]
Doing two consecutive writes?
Rebolek
21:10
No, the first one is commented.
GrahamC
21:10
oh ...
Rebolek
21:11
It's bit messy...
GrahamC
21:12
yeah ..
you have
port: event/port
but then still do write event/port
Rebolek
21:12
yes, but it shouldn't be problem, no? It's copypasted from two different versions...
GrahamC
21:13
It looks good to me .. but I only just woke up
Rebolek
21:14
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
21:15
why are you not using the port returned by 'open?
Rebolek
21:15
you mean like [rp: open rp] ?
21:16
I copied that code from the example on rebol.net
GrahamC
21:17
well, here
https://github.com/rebolek/prot-redis/blob/master/prot-redis.r3#L402
you return the newly opened port .. so I thought you'd use it ?
Last message posted 486 weeks ago.