MEChat 1.2.1 → 1.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/Chat.rb +11 -0
  3. data/client.rb +0 -6
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 556b83c0aefa9cb6249f2c754d1935c62b6b8b111bae62033ccedc8ea5550675
4
- data.tar.gz: f38270047e1275ea3f9a88efc5d000d201bbe5e714c999eaabae6c1f572a21e2
3
+ metadata.gz: 970e7269319bf1254409794849e9a886384b0ac615c58732413cfb0fbaffdb26
4
+ data.tar.gz: 6fbe3b25ef02df8ddd82a5d3de0c49eba494468212d6bffdeb33f3c3e2288575
5
5
  SHA512:
6
- metadata.gz: 8b187f484fa46fc5f3be32f4fbaec2cb03492bc62f37d92c6b520d205a362bfc7cbe9453f041957c4811223ae1352d9a40d29f73a79400c4333f72da444f9081
7
- data.tar.gz: 1aff1558b26d02df3ca12a896675b8fd2d7898839c9c599a2db3df9b4b38a908cee9c73e5d9d9ed83ca9e0eb60152ddf772da129a651770150b0467c8e7b0bf1
6
+ metadata.gz: ffedf600eedfa4bed9334fbafae153135bc288869f1b349598c704c9ca8f166d3992e2581fa8184a5f3280ab5a114114e9fecbafbc74409ac34a7ee2cd1f339e
7
+ data.tar.gz: 1c596f8b598b325f42afbecf91528d3dcfe9779398722c09e38242c9d44a4c9391fd36e05d1989e241917aac66059e403a77a50bb2c80269433864efef0fb9ea
data/Chat.rb CHANGED
@@ -36,10 +36,21 @@ class Chat < DistributedChat::ChatService::Service
36
36
  def request_critical_section(req,_call)
37
37
  request = {:ip => Addrinfo.getaddrinfo(req.username.split(":")[0..-2].join(":"),req.username.split(":")[-1].to_i)[0], :message => req}
38
38
  if $crit_section === 0
39
+ @logger.info "Sent reply to #{request[:ip].ip_address}:#{request[:ip].ip_port}, because I am not in critical section | #{_call}"
39
40
  send_reply ip: request[:ip]
40
41
  elsif $crit_section < 2 && request[:message].timestamp < $alg.clock
42
+ @logger.info "Sent reply to #{request[:ip].ip_address}:#{request[:ip].ip_port}, because I am entering critical section but my request is newer"
41
43
  send_reply ip: request[:ip]
44
+ elsif $crit_section < 2 && request[:message].timestamp === $alg.clock
45
+ if request[:ip].ip_address + ":" + request[:ip].ip_port.to_s < @ip.ip_address + ":" + @port.to_s
46
+ @logger.info "Sent reply to #{request[:ip].ip_address}:#{request[:ip].ip_port}, because I am entering critical section but my request is newer"
47
+ send_reply ip: request[:ip]
48
+ else
49
+ @logger.info "Delayed reply to #{request[:ip].ip_address}:#{request[:ip].ip_port}, because I am entering critical section but my request is older"
50
+ $alg.requests << request
51
+ end
42
52
  else
53
+ @logger.info "Delayed reply to #{request[:ip].ip_address}:#{request[:ip].ip_port}, because I am in critical section"
43
54
  $alg.requests << request
44
55
  end
45
56
  DistributedChat::Response.new status_code: 0
data/client.rb CHANGED
@@ -70,14 +70,8 @@ class Client
70
70
  while new_msg != "exit"
71
71
  $crit_section = 1
72
72
  request_critical_section
73
- sleepdur = 0
74
73
  while $alg.replies.length < $nodes.length
75
- sleepdur += 0.1
76
- @logger.info "#{@ip.ip_address}:#{$port.to_s} waiting for replies"
77
74
  sleep 0.1
78
- if sleepdur % 5 == 0
79
- puts "Waiting for replies. #{$alg.replies.length}/#{$nodes.length} replies received"
80
- end
81
75
  end
82
76
  $crit_section = 2
83
77
  $nodes.each do |node|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: MEChat
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lukas Kaufmann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-08 00:00:00.000000000 Z
11
+ date: 2024-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grpc