Module: Puggernaut::Server::Tcp

Includes:
Logger
Defined in:
lib/puggernaut/server/tcp.rb

Instance Method Summary collapse

Methods included from Logger

#logger, logger

Instance Method Details

#receive_data(data) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/puggernaut/server/tcp.rb', line 7

def receive_data(data)
  messages = data.split("\n").inject({}) do |hash, line|
    channel, message = line.split('|', 2)
    hash[channel] ||= []
    hash[channel] << message
    hash
  end
  Channel.say messages
  send_data "OK\n"
end