我正在尝试使用 FXRuby 制作一个套接字应用程序,并且在添加滚动条之前一切正常,然后应用程序崩溃。
做研究表明线程是问题,但我不知道有什么解决方法。有任何想法吗?
这是导致问题的线程
def listen()
Thread.new() do
begin
loop{
#gets the message from the socket
msg=@socket.gets()
arr=msg.split(' ')
msg=''
case arr[0]
when '/say'
arr.delete_at(0)
arr.each do |word|
msg+=word + ' '
end
add(msg)
when '/cls'
@textArea.removeText(0, @textArea.length)
when '/stp'
abort
when '/conn'
@socket=EzSSL::Client.new(@ip,arr[1].to_i)
@textArea.removeText(0, @textArea.length)
@textArea.appendText("Connected to port #{arr[1]}")
end
}
rescue
#closes the ruby app on exception
abort
end
end
end
add 方法将文本行添加到 FXText 对象
该EzSSL
模块是我创建的一个 gem,用于与 openssl 建立安全套接字连接,并且像普通套接字连接一样工作
我是 Fox-Toolkit 和 FXRuby 的新手,因此感谢您提供任何帮助