Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 47 lines (35 sloc) 1.385 kB
e6dad25 open sourcing this project
Christopher M. Hobbs authored
1 #!/usr/bin/env ruby
2 #
3 # fhpipe - watches southern cad call directories for closed
4 # calls and pipes them to firehouse cad_monitor
5
6 require 'rubygems'
7 require 'eventmachine'
8
9 # some simple config
10 port = 7799
11 host = "localhost"
12 logfile = "C:\\fhpipe_log\\fd.log"
13 cad_incoming = "C:\\cad_incoming\\"
14
15 module EchoServer
16
17 def post_init
18 @log = File.open(logfile, 'a')
19 @log.write("-- [#{Time.now.strftime("%H:%M:%S %d%b%Y").upcase}] CONNECTION ESTABLISHED\n")
20 end
21
22 def receive_data data
23 send_data "-- [#{Time.now.strftime("%H:%M:%S %d%b%Y").upcase}] DATA RECEIVED BY SERVER\n"
24
25 filename = data.split('>')[0]
26 filedata = data.split('>')[1]
27
28 @log.write("-- [#{Time.now.strftime("%H:%M:%S %d%b%Y").upcase}] INCOMING DATA\n")
29 @log.write("-- [#{Time.now.strftime("%H:%M:%S %d%b%Y").upcase}] WRITING TO FILENAME: #{filename}\n")
30
31 # DEBUG
32 # puts filedata
33 File.open(cad_incoming+filename, 'a') {|f| f.write(cad_incoming+filedata) } unless File.exists?(cad_incoming+filename)
34
35 @log.write("\n-- [#{Time.now.strftime("%H:%M:%S %d%b%Y").upcase}] WRITE COMPLETE\n")
36 end
37
38 def unbind
39 @log.write("-- [#{Time.now.strftime("%H:%M:%S %d%b%Y").upcase}] CONNECTION TERMINATED\n")
40 end
41 end
42
43 EventMachine::run {
44 puts "-- [#{Time.now.strftime("%H:%M:%S %d%b%Y").upcase}] LISTENING ON PORT #{port}"
45 EventMachine::start_server host, port, EchoServer
46 }
Something went wrong with that request. Please try again.