S4P2B3FPF57HPHTIAYGMPCVKB7573IB5ZBKNXVBTB6ICCPF55WNQC
module matrix
import net
import sync
struct Channel {
name string
}
pub fn setup(c chan string, addr string, iobuf []byte) {
println('matrix module $addr')
_ := Channel{
name: 'bob'
}
sock := net.dial_tcp(addr) or { panic('connect failed') }
println("succeeded")
mut buf := []byte{len: 1024}
nbytes := sock.read(mut buf) or { panic(err) }
println('$sock $nbytes bytes read')
c <- string(buf)
}
module irc
import net
import sync
struct Channel {
name string
}
pub fn setup(c chan string, addr string, iobuf []byte) {
println('irc module $addr')
_ := Channel{
name: 'bob'
}
sock := net.dial_tcp(addr) or { panic('connect failed') }
mut buf := []byte{len: 1024}
nbytes := sock.read(mut buf) or { panic(err) }
println('$sock $nbytes bytes read')
// unsafe { println(charptr(buf).vstring()) }
// println(buf.bytestr())
c <- string(buf)
}
module main
// system
// local
import time
import irc
import sync
import matrix
fn main() {
mut irc_buf := []byte{len: 1024}
irc_chan := chan string{}
go irc.setup(irc_chan, 'irc.freenode.net:6667', irc_buf)
mut matrix_buf := []byte{len: 1024}
matrix_chan := chan string{}
go matrix.setup(matrix_chan, 'donp.org:32444', matrix_buf)
for {
select {
irc := <-irc_chan {
println('irc: $irc')
}
matrix:= <-matrix_chan {
println('matrix $matrix')
}
> 1 * time.second {
println('select timeout')
}
}
}
}