MEChat 1.5.0 → 1.6.0.wait

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7b0b0a773c231d57e3171ecf0470e072ff4f73822843033d6be17e3aa6964f8b
4
- data.tar.gz: a85c124600569228418a949b486bf7eaf43d3aa4601f70e07ce3edace33b4c32
3
+ metadata.gz: ee5a5e67eab67d9516b8c2bb9bf394d663f468e0472f398d8249c62fe1ba963c
4
+ data.tar.gz: 9df9349c50273ef50425acccbf553f2dee165ec2be3124e34a0339ecb48a1375
5
5
  SHA512:
6
- metadata.gz: 88b6ba28024f7cdce8498be9de5cbff2f49f070a65f98ec5300860aa4bb063efdb35db2c0087416fe9315bdfdc4cde0616a41645351685dd3c35fbc5743ee9f9
7
- data.tar.gz: e42a3ad6645f6bd32c24c44d63d76f414e6e02cdc353e3e0a06e354894c12e405c2e15484ff559e4994ee088860980ffa0e46f5e477bb8b67fc782e57b74bb5b
6
+ metadata.gz: e7b27604d8ad9e714312b6f3bd24d493234f9a7861a389d9001e1ce72fc5655e497f68b299f04242a0f160a87dbe0911e1da787bcd7d7f45bd6fe82b31da4756
7
+ data.tar.gz: 50e65fa60d8203f7d9c919a293ee2a55cc5f2c78ba64f6842e5206affe64c25bc436a593b792fa7d5e5a462fe3b7648b577b1d2ede43f97ddc6bb3e1b452aaa4
data/Chat.rb CHANGED
@@ -8,6 +8,25 @@ this_dir = File.expand_path(File.dirname(__FILE__))
8
8
  lib_dir = File.join(this_dir, 'lib')
9
9
  $LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
10
10
 
11
+ class MessagesEnum
12
+ def initialize(messages)
13
+ @messages = messages
14
+ end
15
+
16
+ def each
17
+ if block_given?
18
+ @messages.each do |msg|
19
+ yield DistributedChat::Request.new(
20
+ username: msg.username,
21
+ message: msg.message,
22
+ timestamp: msg.timestamp
23
+ )
24
+ end
25
+ else
26
+ enum_for(:each)
27
+ end
28
+ end
29
+ end
11
30
  class Chat < DistributedChat::ChatService::Service
12
31
 
13
32
  def initialize ip,port,node_service
@@ -61,4 +80,8 @@ class Chat < DistributedChat::ChatService::Service
61
80
  $alg.clock = [req.timestamp,$alg.clock].max + 1
62
81
  DistributedChat::Response.new status_code: 0
63
82
  end
83
+
84
+ def get_messages(req,_call)
85
+ MessagesEnum.new($messages).each
86
+ end
64
87
  end
data/client.rb CHANGED
@@ -21,7 +21,13 @@ class Client
21
21
  nodediscovery.register_node(DistributedChat::NodeInfo.new(address: @ip.ip_address, port: $port)).each do |node|
22
22
  $nodes.push node
23
23
  end
24
-
24
+ chat = DistributedChat::ChatService::Stub.new("#{ip.ip_address}:#{ip.ip_port}", :this_channel_is_insecure)
25
+ chat.get_messages(DistributedChat::Empty.new).each do |msg|
26
+ $messages << msg
27
+ end
28
+ $messages.each do |msg|
29
+ puts "#{msg.username}: #{msg.message}"
30
+ end
25
31
  end
26
32
 
27
33
  private def request_critical_section
@@ -74,7 +80,7 @@ class Client
74
80
  sleep 0.1
75
81
  end
76
82
  $crit_section = 2
77
- # gets
83
+ sleep 20
78
84
  $nodes.each do |node|
79
85
  chat = DistributedChat::ChatService::Stub.new("#{node.address}:#{node.port}", :this_channel_is_insecure)
80
86
  chat.send_message(DistributedChat::Request.new(username: "#{@ip.ip_address}:#{$port.to_s}", message: new_msg, timestamp: $alg.clock))
data/lib/MEChat_pb.rb CHANGED
@@ -5,7 +5,7 @@
5
5
  require 'google/protobuf'
6
6
 
7
7
 
8
- descriptor_data = "\n\x0cMEChat.proto\x12\x10\x64istributed_chat\"?\n\x07Request\x12\x10\n\x08username\x18\x01 \x01(\t\x12\x0f\n\x07message\x18\x02 \x01(\t\x12\x11\n\ttimestamp\x18\x03 \x01(\x05\"\x1f\n\x08Response\x12\x13\n\x0bstatus_code\x18\x01 \x01(\x05\"O\n\x08NodeInfo\x12\x0f\n\x07\x61\x64\x64ress\x18\x01 \x01(\t\x12\x0c\n\x04port\x18\x02 \x01(\x05\x12\x16\n\ttimestamp\x18\x03 \x01(\x05H\x00\x88\x01\x01\x42\x0c\n\n_timestamp2\xf5\x01\n\x0b\x43hatService\x12\x44\n\x0bSendMessage\x12\x19.distributed_chat.Request\x1a\x1a.distributed_chat.Response\x12O\n\x16RequestCriticalSection\x12\x19.distributed_chat.Request\x1a\x1a.distributed_chat.Response\x12O\n\x16ReleaseCriticalSection\x12\x19.distributed_chat.Request\x1a\x1a.distributed_chat.Response2\xe8\x01\n\rNodeDiscovery\x12H\n\x0cRegisterNode\x12\x1a.distributed_chat.NodeInfo\x1a\x1a.distributed_chat.NodeInfo0\x01\x12\x43\n\x08GetNodes\x12\x19.distributed_chat.Request\x1a\x1a.distributed_chat.NodeInfo0\x01\x12H\n\x0e\x44\x65registerNode\x12\x1a.distributed_chat.NodeInfo\x1a\x1a.distributed_chat.ResponseB\t\xaa\x02\x06MEChatb\x06proto3"
8
+ descriptor_data = "\n\x0cMEChat.proto\x12\x10\x64istributed_chat\"?\n\x07Request\x12\x10\n\x08username\x18\x01 \x01(\t\x12\x0f\n\x07message\x18\x02 \x01(\t\x12\x11\n\ttimestamp\x18\x03 \x01(\x05\"\x1f\n\x08Response\x12\x13\n\x0bstatus_code\x18\x01 \x01(\x05\"\x07\n\x05\x45mpty\"O\n\x08NodeInfo\x12\x0f\n\x07\x61\x64\x64ress\x18\x01 \x01(\t\x12\x0c\n\x04port\x18\x02 \x01(\x05\x12\x16\n\ttimestamp\x18\x03 \x01(\x05H\x00\x88\x01\x01\x42\x0c\n\n_timestamp2\xba\x02\n\x0b\x43hatService\x12\x44\n\x0bSendMessage\x12\x19.distributed_chat.Request\x1a\x1a.distributed_chat.Response\x12O\n\x16RequestCriticalSection\x12\x19.distributed_chat.Request\x1a\x1a.distributed_chat.Response\x12O\n\x16ReleaseCriticalSection\x12\x19.distributed_chat.Request\x1a\x1a.distributed_chat.Response\x12\x43\n\x0bGetMessages\x12\x17.distributed_chat.Empty\x1a\x19.distributed_chat.Request0\x01\x32\xe8\x01\n\rNodeDiscovery\x12H\n\x0cRegisterNode\x12\x1a.distributed_chat.NodeInfo\x1a\x1a.distributed_chat.NodeInfo0\x01\x12\x43\n\x08GetNodes\x12\x19.distributed_chat.Request\x1a\x1a.distributed_chat.NodeInfo0\x01\x12H\n\x0e\x44\x65registerNode\x12\x1a.distributed_chat.NodeInfo\x1a\x1a.distributed_chat.ResponseB\t\xaa\x02\x06MEChatb\x06proto3"
9
9
 
10
10
  pool = Google::Protobuf::DescriptorPool.generated_pool
11
11
 
@@ -34,5 +34,6 @@ end
34
34
  module DistributedChat
35
35
  Request = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("distributed_chat.Request").msgclass
36
36
  Response = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("distributed_chat.Response").msgclass
37
+ Empty = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("distributed_chat.Empty").msgclass
37
38
  NodeInfo = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("distributed_chat.NodeInfo").msgclass
38
39
  end
@@ -20,6 +20,8 @@ module DistributedChat
20
20
  rpc :RequestCriticalSection, ::DistributedChat::Request, ::DistributedChat::Response
21
21
  # Method to release access to the critical section
22
22
  rpc :ReleaseCriticalSection, ::DistributedChat::Request, ::DistributedChat::Response
23
+ # Method to request the current chat log
24
+ rpc :GetMessages, ::DistributedChat::Empty, stream(::DistributedChat::Request)
23
25
  end
24
26
 
25
27
  Stub = Service.rpc_stub_class
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.5.0
4
+ version: 1.6.0.wait
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-09 00:00:00.000000000 Z
11
+ date: 2024-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grpc
@@ -140,9 +140,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
140
140
  version: '0'
141
141
  required_rubygems_version: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - ">="
143
+ - - ">"
144
144
  - !ruby/object:Gem::Version
145
- version: '0'
145
+ version: 1.3.1
146
146
  requirements: []
147
147
  rubygems_version: 3.4.10
148
148
  signing_key: