Class: IrcCat::TcpServer
- Inherits:
-
Object
- Object
- IrcCat::TcpServer
- Defined in:
- lib/irc_cat/tcp_server.rb
Instance Method Summary collapse
-
#initialize(bot, config, ip = '127.0.0.1', port = '8080') ⇒ TcpServer
constructor
A new instance of TcpServer.
Constructor Details
#initialize(bot, config, ip = '127.0.0.1', port = '8080') ⇒ TcpServer
Returns a new instance of TcpServer.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/irc_cat/tcp_server.rb', line 5 def initialize(bot,config,ip='127.0.0.1',port='8080') @socket = TCPserver.new(ip,port) puts "Starting TCP (#{ip}:#{port})" loop do Thread.start(@socket.accept) do |s| str = s.recv( 400 ) sstr = str.split(/\n/) sstr.each do |l| bot.say(config['irc']['channel'],"#{l}") end s.close end # |s| end # loop end |