ruby_kpi 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/lib/DataStructures.rb +90 -0
- data/lib/ReplyMessage.rb +384 -0
- data/lib/SSAP_templates.rb +132 -0
- data/lib/TCPConnection.rb +56 -0
- data/lib/ruby_kpi/version.rb +3 -0
- data/lib/ruby_kpi.rb +723 -0
- data/ruby_kpi.gemspec +28 -0
- metadata +139 -0
@@ -0,0 +1,56 @@
|
|
1
|
+
##################################################
|
2
|
+
#
|
3
|
+
# The TCPConnection class
|
4
|
+
#
|
5
|
+
##################################################
|
6
|
+
|
7
|
+
module RubyKpi
|
8
|
+
|
9
|
+
class TCPConnection
|
10
|
+
|
11
|
+
# Constructor
|
12
|
+
def initialize(ip, port)
|
13
|
+
|
14
|
+
# Read parameters
|
15
|
+
@ip = ip
|
16
|
+
@port = port
|
17
|
+
|
18
|
+
# Connect
|
19
|
+
begin
|
20
|
+
@sib_socket = TCPSocket.new(@ip, @port)
|
21
|
+
rescue Errno::ECONNREFUSED
|
22
|
+
raise SIBError, 'Connection refused'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Send the request message
|
27
|
+
def send_request(msg)
|
28
|
+
@sib_socket.write(msg)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Receive the reply
|
32
|
+
def receive_reply()
|
33
|
+
rmsg = ""
|
34
|
+
while true do
|
35
|
+
begin
|
36
|
+
r = @sib_socket.recv(4096)
|
37
|
+
rmsg += r
|
38
|
+
if rmsg.include?("</SSAP_message>")
|
39
|
+
break
|
40
|
+
end
|
41
|
+
rescue
|
42
|
+
raise SIBError, 'Error while receiving a reply'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
return rmsg
|
47
|
+
end
|
48
|
+
|
49
|
+
# Close the connection
|
50
|
+
def close()
|
51
|
+
@sib_socket.close()
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|