conreality 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: df892d6caf11ad3f9fcb527807a7cf78c718eed71e71e18c6a7c12798577604d
4
+ data.tar.gz: 8ebee26f5b26f9345081ab9fb1fc96b410feaac46ab3ea134974ed2d88707a16
5
+ SHA512:
6
+ metadata.gz: ef4941aff380f0e717a2f7ae685ec51938a2bc0f064950b6c38d4955fe6486e7dafdb31e1a7c529942caa030d29cc537a869a77c1727345924dbd2cdf6057948
7
+ data.tar.gz: 29cbab1eafee83fa1b1ab7f4bba8363c703b5c1be7433fa94f8fa162a86d276115e6707c2077691556bd8567b641cc46fb4108c29919d83d91c4091d146f6118
data/AUTHORS ADDED
@@ -0,0 +1 @@
1
+ * Arto Bendiken <arto@conreality.org>
@@ -0,0 +1,3 @@
1
+ *******
2
+ Credits
3
+ *******
data/README ADDED
@@ -0,0 +1,6 @@
1
+ Conreality Software Development Kit (SDK) for Ruby
2
+ ==================================================
3
+
4
+ See <https://sdk.conreality.org/ruby/> for documentation.
5
+
6
+ Use <https://github.com/conreality/conreality.rb/issues> for bug reports.
@@ -0,0 +1,24 @@
1
+ This is free and unencumbered software released into the public domain.
2
+
3
+ Anyone is free to copy, modify, publish, use, compile, sell, or
4
+ distribute this software, either in source code form or as a compiled
5
+ binary, for any purpose, commercial or non-commercial, and by any
6
+ means.
7
+
8
+ In jurisdictions that recognize copyright laws, the author or authors
9
+ of this software dedicate any and all copyright interest in the
10
+ software to the public domain. We make this dedication for the benefit
11
+ of the public at large and to the detriment of our heirs and
12
+ successors. We intend this dedication to be an overt act of
13
+ relinquishment in perpetuity of all present and future rights to this
14
+ software under copyright law.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ For more information, please refer to <https://unlicense.org/>
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.4
@@ -0,0 +1,18 @@
1
+ # This is free and unencumbered software released into the public domain.
2
+
3
+ require_relative 'conreality/version'
4
+
5
+ #require_relative 'conreality/object'
6
+ #require_relative 'conreality/asset'
7
+ #require_relative 'conreality/camera'
8
+ #require_relative 'conreality/player'
9
+
10
+ #require_relative 'conreality/binary'
11
+ require_relative 'conreality/event'
12
+ require_relative 'conreality/message'
13
+ #require_relative 'conreality/theater'
14
+
15
+ #require_relative 'conreality/action'
16
+ require_relative 'conreality/client'
17
+ require_relative 'conreality/game'
18
+ require_relative 'conreality/session'
@@ -0,0 +1,62 @@
1
+ # This is free and unencumbered software released into the public domain.
2
+
3
+ module Conreality
4
+ ##
5
+ # A transaction-scoped action.
6
+ class Action
7
+ ##
8
+ # The client session this actions belongs to.
9
+ #
10
+ # @return [Session]
11
+ attr_reader :session
12
+
13
+ ##
14
+ # @param session [Session]
15
+ def initialize(session)
16
+ @session = session
17
+ end
18
+
19
+ ##
20
+ # Returns a developer-friendly representation of this action.
21
+ #
22
+ # @return [String]
23
+ def inspect
24
+ sprintf("#<%s:%#0x>", self.class.name, self.__id__)
25
+ end
26
+
27
+ # @!group Events
28
+
29
+ ##
30
+ # @param predicate [String] a predicate string
31
+ # @param subject [Object, UUID] the source object
32
+ # @param object [Object, UUID, nil] the target object, if any
33
+ # @return [Event] the sent event
34
+ def send_event(predicate, subject, object = nil)
35
+ predicate = predicate.to_s
36
+ subject = (subject.respond_to?(:uuid) ? subject.uuid : subject).to_s
37
+ object = object ? (object.respond_to?(:uuid) ? object.uuid : object).to_s : nil
38
+
39
+ result = @session.client.call_proc_with_result(:event_send, args: [predicate, subject, object])
40
+ result ? Conreality::Event.new(@session, result.to_i) : nil
41
+ end
42
+
43
+ # @!endgroup
44
+
45
+ # @!group Messaging
46
+
47
+ ##
48
+ # @param sender [Object, UUID] the sending asset or player
49
+ # @param text [String] the message contents as text
50
+ # @return [Message] the sent message
51
+ # @todo Support for audio messages.
52
+ def send_message(sender, text)
53
+ sender = (sender.respond_to?(:uuid) ? sender.uuid : sender).to_s
54
+ text = text.to_s
55
+
56
+ result = @session.client.call_proc_with_result(:message_send, args: [sender, text])
57
+ result ? Conreality::Message.new(@session, result.to_i) : nil
58
+ end
59
+
60
+ # @!endgroup
61
+ end # Action
62
+ end # Conreality
@@ -0,0 +1,48 @@
1
+ # This is free and unencumbered software released into the public domain.
2
+
3
+ module Conreality
4
+ ##
5
+ # Represents a Conreality asset.
6
+ class Asset < Object
7
+ TABLE = :object_asset
8
+ KEY = :uuid
9
+
10
+ ##
11
+ # The asset's nickname.
12
+ #
13
+ # @return [String]
14
+ attr_accessor :nick
15
+
16
+ ##
17
+ # The asset's full name.
18
+ #
19
+ # @return [String]
20
+ attr_accessor :name
21
+
22
+ ##
23
+ # The asset's IPv4/IPv6 address.
24
+ #
25
+ # @return [String]
26
+ attr_accessor :ip_addr
27
+
28
+ ##
29
+ # The asset's avatar image.
30
+ #
31
+ # @return [Binary]
32
+ attr_accessor :avatar
33
+ attr_wrapper :avatar, :Binary
34
+
35
+ ##
36
+ # The asset's deployed software version.
37
+ #
38
+ # @return [String]
39
+ attr_accessor :version
40
+
41
+ ##
42
+ # @param session [Session]
43
+ # @param uuid [#to_s]
44
+ def initialize(session, uuid)
45
+ super(session, uuid)
46
+ end
47
+ end # Asset
48
+ end # Conreality
@@ -0,0 +1,50 @@
1
+ # This is free and unencumbered software released into the public domain.
2
+
3
+ module Conreality
4
+ ##
5
+ # Represents a Conreality binary.
6
+ class Binary #< Database::Row
7
+ TABLE = :binary
8
+ KEY = :id
9
+
10
+ ##
11
+ # The binary's sequential identifier.
12
+ #
13
+ # @return [Integer]
14
+ attr_reader :id
15
+
16
+ ##
17
+ # The binary's unique identifier (SHA-256 fingerprint).
18
+ #
19
+ # @return [String]
20
+ attr_reader :sha256
21
+
22
+ ##
23
+ # The binary's MIME content type.
24
+ #
25
+ # @return [String]
26
+ attr_accessor :type
27
+
28
+ ##
29
+ # The binary data.
30
+ #
31
+ # @return [String]
32
+ attr_reader :data
33
+
34
+ ##
35
+ # @param session [Session]
36
+ # @param id [#to_i]
37
+ def initialize(session, id)
38
+ super(session)
39
+ @id = id.to_i
40
+ end
41
+
42
+ ##
43
+ # Returns a developer-friendly representation of this binary.
44
+ #
45
+ # @return [String]
46
+ def inspect
47
+ sprintf("#<%s:%#0x(id: %s)>", self.class.name, self.__id__, @id)
48
+ end
49
+ end # Binary
50
+ end # Conreality
@@ -0,0 +1,41 @@
1
+ # This is free and unencumbered software released into the public domain.
2
+
3
+ module Conreality
4
+ ##
5
+ # Represents a Conreality camera.
6
+ class Camera < Object
7
+ TABLE = :object_camera
8
+ KEY = :uuid
9
+
10
+ ##
11
+ # The camera's resolution (in 2D pixels).
12
+ #
13
+ # @return [Array(Integer, Integer)]
14
+ attr_accessor :resolution
15
+
16
+ ##
17
+ # The camera's image format.
18
+ #
19
+ # @return [String]
20
+ attr_accessor :format
21
+
22
+ ##
23
+ # The camera's frame rate (per second).
24
+ #
25
+ # @return [Integer]
26
+ attr_accessor :fps
27
+
28
+ ##
29
+ # The camera's f-number (the f/N focal ratio).
30
+ #
31
+ # @return [Integer]
32
+ attr_accessor :fnumber
33
+
34
+ ##
35
+ # @param session [Session]
36
+ # @param uuid [#to_s]
37
+ def initialize(session, uuid)
38
+ super(session, uuid)
39
+ end
40
+ end # Camera
41
+ end # Conreality
@@ -0,0 +1,105 @@
1
+ # This is free and unencumbered software released into the public domain.
2
+
3
+ require 'uuid'
4
+
5
+ require_relative 'rpc'
6
+ require_relative 'session'
7
+ require_relative 'version'
8
+
9
+ module Conreality
10
+ ##
11
+ # Client for accessing a Conreality master server.
12
+ class Client
13
+ attr_reader :rpc_public
14
+ attr_reader :rpc_session
15
+
16
+ ##
17
+ # @param master_host [String]
18
+ def self.connect(master_host, *args)
19
+ self.new(master_host, *args).connect
20
+ end
21
+
22
+ ##
23
+ # @param master_host [String]
24
+ def initialize(master_host)
25
+ channel_creds = :this_channel_is_insecure
26
+ @channel = RPC::Session::Stub.setup_channel(nil, master_host, channel_creds)
27
+ @rpc_public = RPC::Public::Stub.new(master_host, channel_creds, channel_override: @channel)
28
+ @rpc_session = RPC::Session::Stub.new(master_host, channel_creds, channel_override: @channel)
29
+ end
30
+
31
+ ##
32
+ # Returns a developer-friendly representation of this client.
33
+ #
34
+ # @return [String]
35
+ def inspect
36
+ sprintf("#<%s:%#0x>", self.class.name, self.__id__)
37
+ end
38
+
39
+ # @!group Connection management
40
+
41
+ ##
42
+ # Connects to the server.
43
+ #
44
+ # @return [Client] `self`
45
+ def connect
46
+ self
47
+ end
48
+
49
+ ##
50
+ # Disconnects from the server.
51
+ #
52
+ # @return [void]
53
+ def disconnect!
54
+ @channel = @rpc_public = @rpc_session = nil
55
+ end
56
+
57
+ # @!endgroup
58
+
59
+ # @!group Public interface
60
+
61
+ ##
62
+ # Invokes the public `Authenticate` method on the server.
63
+ #
64
+ # @param agent_uuid [String]
65
+ # @param secret [String]
66
+ # @return [Session]
67
+ def authenticate(agent_uuid, secret = nil)
68
+ Session.new(self, 1) # TODO
69
+ end
70
+
71
+ ##
72
+ # Invokes the public `Bye` method on the server.
73
+ #
74
+ # @return [void]
75
+ def bye
76
+ @rpc_public.bye(RPC::EmptyRequest.new)
77
+ end
78
+
79
+ ##
80
+ # Invokes the public `Hello` method on the server.
81
+ #
82
+ # @return [Hash]
83
+ def hello
84
+ {version: @rpc_public.hello(RPC::HelloRequest.new(version: Conreality::VERSION.to_s)).version}.freeze
85
+ end
86
+
87
+ ##
88
+ # Invokes the public `Ping` method on the server.
89
+ #
90
+ # @return [void]
91
+ def ping
92
+ @rpc_public.ping(RPC::PingRequest.new)
93
+ end
94
+
95
+ # @!endgroup
96
+
97
+ # @!group Session interface
98
+
99
+ # @!endgroup
100
+
101
+ private
102
+
103
+ # TODO
104
+ end # Client
105
+ end # Conreality
@@ -0,0 +1,57 @@
1
+ # This is free and unencumbered software released into the public domain.
2
+
3
+ module Conreality
4
+ ##
5
+ # Represents a Conreality event.
6
+ class Event
7
+ TABLE = :event
8
+ KEY = :id
9
+
10
+ ##
11
+ # The event's sequential identifier.
12
+ #
13
+ # @return [Integer]
14
+ attr_reader :id
15
+
16
+ ##
17
+ # The event's timestamp (in Zulu time).
18
+ #
19
+ # @return [Time]
20
+ attr_reader :timestamp
21
+
22
+ ##
23
+ # The event's predicate (an action or verb).
24
+ #
25
+ # @return [Symbol]
26
+ attr_reader :predicate
27
+
28
+ ##
29
+ # The subject (i.e., source) of the predicate.
30
+ #
31
+ # @return [Object]
32
+ attr_reader :subject
33
+ #attr_wrapper :subject, :Object
34
+
35
+ ##
36
+ # The object (i.e., target) of the predicate.
37
+ #
38
+ # @return [Object]
39
+ attr_reader :object
40
+ #attr_wrapper :object, :Object
41
+
42
+ ##
43
+ # @param session [Session]
44
+ # @param id [#to_i]
45
+ def initialize(session, id)
46
+ @session, @id = session, id.to_i
47
+ end
48
+
49
+ ##
50
+ # Returns a developer-friendly representation of this event.
51
+ #
52
+ # @return [String]
53
+ def inspect
54
+ sprintf("#<%s:%#0x(id: %s)>", self.class.name, self.__id__, @id)
55
+ end
56
+ end # Event
57
+ end # Conreality
@@ -0,0 +1,81 @@
1
+ # This is free and unencumbered software released into the public domain.
2
+
3
+ module Conreality
4
+ ##
5
+ # The game database.
6
+ class Game
7
+ ##
8
+ # @param session [Session]
9
+ def initialize(session)
10
+ @session = session
11
+ end
12
+
13
+ ##
14
+ # Returns a developer-friendly representation of this action.
15
+ #
16
+ # @return [String]
17
+ def inspect
18
+ sprintf("#<%s:%#0x>", self.class.name, self.__id__)
19
+ end
20
+
21
+ # @!group Theaters
22
+
23
+ ##
24
+ # Returns the theater identified by the given UUID.
25
+ #
26
+ # @param uuid [String] the theater's UUID
27
+ # @return [Theater] the theater
28
+ def find_theater(uuid)
29
+ Conreality::Theater.new(@session, uuid)
30
+ end
31
+
32
+ ##
33
+ # @todo
34
+ def each_theater(&block)
35
+ # TODO
36
+ end
37
+
38
+ # @!endgroup
39
+
40
+ # @!group Objects
41
+
42
+ ##
43
+ # Returns the object identified by the given UUID.
44
+ #
45
+ # @param uuid [String] the object's UUID
46
+ # @return [Object] the object
47
+ def find_object(uuid)
48
+ Conreality::Object.new(@session, uuid)
49
+ end
50
+
51
+ ##
52
+ # @todo
53
+ def each_object(&block)
54
+ # TODO
55
+ end
56
+
57
+ # @!endgroup
58
+
59
+ # @!group Events
60
+
61
+ ##
62
+ # @todo
63
+ # @return [Event] the event
64
+ def find_event(id)
65
+ # TODO
66
+ end
67
+
68
+ # @!endgroup
69
+
70
+ # @!group Messaging
71
+
72
+ ##
73
+ # @todo
74
+ # @return [Message] the message
75
+ def find_message(id)
76
+ # TODO
77
+ end
78
+
79
+ # @!endgroup
80
+ end # Game
81
+ end # Conreality
@@ -0,0 +1,57 @@
1
+ # This is free and unencumbered software released into the public domain.
2
+
3
+ module Conreality
4
+ ##
5
+ # Represents a Conreality message.
6
+ class Message
7
+ TABLE = :message
8
+ KEY = :id
9
+
10
+ ##
11
+ # The message's sequential identifier.
12
+ #
13
+ # @return [Integer]
14
+ attr_reader :id
15
+
16
+ ##
17
+ # The message's timestamp (in Zulu time).
18
+ #
19
+ # @return [Time]
20
+ attr_reader :timestamp
21
+
22
+ ##
23
+ # The sender of the message.
24
+ #
25
+ # @return [Player, Asset]
26
+ attr_reader :sender
27
+ #attr_wrapper :sender, :Object
28
+
29
+ ##
30
+ # The message's contents as text.
31
+ #
32
+ # @return [String]
33
+ attr_reader :text
34
+
35
+ ##
36
+ # The message's contents as audio.
37
+ #
38
+ # @return [Binary]
39
+ attr_reader :audio
40
+ #attr_wrapper :audio, :Binary
41
+
42
+ ##
43
+ # @param session [Session]
44
+ # @param id [#to_i]
45
+ def initialize(session, id)
46
+ @session, @id = session, id.to_i
47
+ end
48
+
49
+ ##
50
+ # Returns a developer-friendly representation of this message.
51
+ #
52
+ # @return [String]
53
+ def inspect
54
+ sprintf("#<%s:%#0x(id: %s)>", self.class.name, self.__id__, @id)
55
+ end
56
+ end # Message
57
+ end # Conreality
@@ -0,0 +1,163 @@
1
+ # This is free and unencumbered software released into the public domain.
2
+
3
+ module Conreality
4
+ ##
5
+ # Represents a Conreality object.
6
+ class Object #< Database::Row
7
+ TABLE = :object
8
+ KEY = :uuid
9
+
10
+ ##
11
+ # The object's unique identifier.
12
+ #
13
+ # @return [String]
14
+ attr_reader :uuid
15
+
16
+ ##
17
+ # The object's type.
18
+ #
19
+ # @return [Symbol]
20
+ attr_reader :type
21
+
22
+ ##
23
+ # The theater that the object is located in.
24
+ #
25
+ # @return [Theater]
26
+ attr_accessor :theater
27
+
28
+ ##
29
+ # The group, if any, that the object belongs to.
30
+ #
31
+ # @return [Group]
32
+ attr_accessor :group
33
+
34
+ ##
35
+ # The object's designated label.
36
+ #
37
+ # @return [String]
38
+ attr_accessor :label
39
+
40
+ ##
41
+ # The object's current position (as 3D coordinates relative to its theater).
42
+ #
43
+ # @return [?]
44
+ attr_accessor :position
45
+
46
+ ##
47
+ # The object's current orientation (in radians relative to north).
48
+ #
49
+ # @return [Float]
50
+ attr_accessor :orientation
51
+
52
+ ##
53
+ # The object's estimated mass (in kilograms).
54
+ #
55
+ # @return [Float]
56
+ attr_accessor :mass
57
+
58
+ ##
59
+ # The object's determined radius (in meters).
60
+ #
61
+ # @return [Float]
62
+ attr_accessor :radius
63
+
64
+ ##
65
+ # The object's estimated color (as a 24-bit RGB value).
66
+ #
67
+ # @return [Integer]
68
+ attr_accessor :color
69
+
70
+ ##
71
+ # @param session [Session]
72
+ # @param uuid [#to_s]
73
+ def initialize(session, uuid)
74
+ super(session)
75
+ @uuid = uuid.to_s.freeze
76
+ end
77
+
78
+ ##
79
+ # Returns a developer-friendly representation of this object.
80
+ #
81
+ # @return [String]
82
+ def inspect
83
+ sprintf("#<%s:%#0x(uuid: %s)>", self.class.name, self.__id__, @uuid)
84
+ end
85
+
86
+ # @!group Casts
87
+
88
+ ##
89
+ # Returns this object cast to an asset.
90
+ #
91
+ # @return [Asset]
92
+ def as_asset
93
+ Asset.new(@session, @uuid)
94
+ end
95
+
96
+ ##
97
+ # Returns this object cast to a camera.
98
+ #
99
+ # @return [Camera]
100
+ def as_camera
101
+ Camera.new(@session, @uuid)
102
+ end
103
+
104
+ ##
105
+ # Returns this object cast to a player.
106
+ #
107
+ # @return [Player]
108
+ def as_player
109
+ Player.new(@session, @uuid)
110
+ end
111
+
112
+ # @!endgroup
113
+
114
+ # @!group Predicates
115
+
116
+ ##
117
+ # Checks whether this object is an asset.
118
+ #
119
+ # @return [Boolean]
120
+ def is_asset?
121
+ nil # TODO
122
+ end
123
+
124
+ ##
125
+ # Checks whether this object is a camera.
126
+ #
127
+ # @return [Boolean]
128
+ def is_camera?
129
+ nil # TODO
130
+ end
131
+
132
+ ##
133
+ # Checks whether this object is a player.
134
+ #
135
+ # @return [Boolean]
136
+ def is_player?
137
+ nil # TODO
138
+ end
139
+
140
+ ##
141
+ # Checks whether this object is a target.
142
+ #
143
+ # @return [Boolean]
144
+ def is_target?
145
+ nil # TODO
146
+ end
147
+
148
+ # @!endgroup
149
+
150
+ # @!group Messaging
151
+
152
+ ##
153
+ # @param text [String] the message contents as text
154
+ # @return [Message] the sent message
155
+ def send_message(text)
156
+ @session.execute do |action| # FIXME
157
+ action.send_message(self, text)
158
+ end
159
+ end
160
+
161
+ # @!endgroup
162
+ end # Object
163
+ end # Conreality
@@ -0,0 +1,74 @@
1
+ # This is free and unencumbered software released into the public domain.
2
+
3
+ module Conreality
4
+ ##
5
+ # Represents a Conreality player.
6
+ class Player < Object
7
+ TABLE = :object_player
8
+ KEY = :uuid
9
+
10
+ ##
11
+ # The player's nickname.
12
+ #
13
+ # @return [String]
14
+ attr_accessor :nick
15
+
16
+ ##
17
+ # The player's full name.
18
+ #
19
+ # @return [String]
20
+ attr_accessor :name
21
+
22
+ ##
23
+ # The player's IPv4/IPv6 address.
24
+ #
25
+ # @return [String]
26
+ attr_accessor :ip_addr
27
+
28
+ ##
29
+ # The player's avatar image.
30
+ #
31
+ # @return [Binary]
32
+ attr_accessor :avatar
33
+ attr_wrapper :avatar, :Binary
34
+
35
+ ##
36
+ # The player's primary language.
37
+ #
38
+ # @return [String]
39
+ attr_accessor :language
40
+
41
+ ##
42
+ # @param session [Session]
43
+ # @param uuid [#to_s]
44
+ def initialize(session, uuid)
45
+ super(session, uuid)
46
+ end
47
+
48
+ ##
49
+ # Checks whether this player has a bodycam.
50
+ #
51
+ # @return [Boolean]
52
+ def has_camera?
53
+ @session.client.exec_with_params("SELECT COUNT(*) FROM #{q(Database::SCHEMA)}.#{q(:camera)} WHERE #{q(:uuid)} = $1 LIMIT 1", self.key) do |result|
54
+ !!result.num_tuples.nonzero?
55
+ end
56
+ end
57
+
58
+ ##
59
+ # Returns the bodycam, if any, of this player.
60
+ #
61
+ # @return [Camera, nil]
62
+ def camera
63
+ self.has_camera? ? self.as_camera : nil
64
+ end
65
+
66
+ ##
67
+ # Deregisters this player from the game.
68
+ #
69
+ # @return [void]
70
+ def deregister!
71
+ # TODO
72
+ end
73
+ end # Player
74
+ end # Conreality
@@ -0,0 +1,6 @@
1
+ # This is free and unencumbered software released into the public domain.
2
+
3
+ require_relative 'rpc/common_pb'
4
+ require_relative 'rpc/model_pb'
5
+ require_relative 'rpc/master_pb'
6
+ require_relative 'rpc/master_services_pb'
@@ -0,0 +1,36 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: conreality/rpc/common.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ Google::Protobuf::DescriptorPool.generated_pool.build do
7
+ add_message "Conreality.RPC.EmptyRequest" do
8
+ end
9
+ add_message "Conreality.RPC.EmptyResponse" do
10
+ end
11
+ add_message "Conreality.RPC.IDResponse" do
12
+ optional :id, :uint64, 1
13
+ end
14
+ add_message "Conreality.RPC.PingRequest" do
15
+ end
16
+ add_message "Conreality.RPC.PongResponse" do
17
+ end
18
+ add_message "Conreality.RPC.HelloRequest" do
19
+ optional :version, :string, 1
20
+ end
21
+ add_message "Conreality.RPC.HelloResponse" do
22
+ optional :version, :string, 1
23
+ end
24
+ end
25
+
26
+ module Conreality
27
+ module RPC
28
+ EmptyRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("Conreality.RPC.EmptyRequest").msgclass
29
+ EmptyResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("Conreality.RPC.EmptyResponse").msgclass
30
+ IDResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("Conreality.RPC.IDResponse").msgclass
31
+ PingRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("Conreality.RPC.PingRequest").msgclass
32
+ PongResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("Conreality.RPC.PongResponse").msgclass
33
+ HelloRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("Conreality.RPC.HelloRequest").msgclass
34
+ HelloResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("Conreality.RPC.HelloResponse").msgclass
35
+ end
36
+ end
@@ -0,0 +1,39 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: conreality/rpc/master.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ require 'conreality/rpc/model_pb'
7
+ require 'conreality/rpc/common_pb'
8
+ Google::Protobuf::DescriptorPool.generated_pool.build do
9
+ add_message "Conreality.RPC.AuthRequest" do
10
+ optional :player_nick, :string, 1
11
+ end
12
+ add_message "Conreality.RPC.AuthResponse" do
13
+ optional :session_id, :uint64, 1
14
+ end
15
+ add_message "Conreality.RPC.SendEventRequest" do
16
+ optional :session_id, :uint64, 1
17
+ optional :predicate, :string, 2
18
+ optional :subject_uuid, :string, 3
19
+ optional :object_uuid, :string, 4
20
+ end
21
+ add_message "Conreality.RPC.SendMessageRequest" do
22
+ optional :session_id, :uint64, 1
23
+ optional :text, :string, 2
24
+ end
25
+ add_message "Conreality.RPC.UpdatePlayerRequest" do
26
+ optional :session_id, :uint64, 1
27
+ optional :heartbeat, :uint32, 2
28
+ end
29
+ end
30
+
31
+ module Conreality
32
+ module RPC
33
+ AuthRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("Conreality.RPC.AuthRequest").msgclass
34
+ AuthResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("Conreality.RPC.AuthResponse").msgclass
35
+ SendEventRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("Conreality.RPC.SendEventRequest").msgclass
36
+ SendMessageRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("Conreality.RPC.SendMessageRequest").msgclass
37
+ UpdatePlayerRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("Conreality.RPC.UpdatePlayerRequest").msgclass
38
+ end
39
+ end
@@ -0,0 +1,47 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # Source: conreality/rpc/master.proto for package 'Conreality.RPC'
3
+ # Original file comments:
4
+ # This is free and unencumbered software released into the public domain.
5
+ #
6
+
7
+ require 'grpc'
8
+ require 'conreality/rpc/master_pb'
9
+
10
+ module Conreality
11
+ module RPC
12
+ module Public
13
+ class Service
14
+
15
+ include GRPC::GenericService
16
+
17
+ self.marshal_class_method = :encode
18
+ self.unmarshal_class_method = :decode
19
+ self.service_name = 'Conreality.RPC.Public'
20
+
21
+ rpc :Authenticate, AuthRequest, AuthResponse
22
+ rpc :Bye, EmptyRequest, EmptyResponse
23
+ rpc :Hello, HelloRequest, HelloResponse
24
+ rpc :Ping, PingRequest, PongResponse
25
+ end
26
+
27
+ Stub = Service.rpc_stub_class
28
+ end
29
+ module Session
30
+ class Service
31
+
32
+ include GRPC::GenericService
33
+
34
+ self.marshal_class_method = :encode
35
+ self.unmarshal_class_method = :decode
36
+ self.service_name = 'Conreality.RPC.Session'
37
+
38
+ rpc :Ping, PingRequest, PongResponse
39
+ rpc :SendEvent, SendEventRequest, IDResponse
40
+ rpc :SendMessage, SendMessageRequest, IDResponse
41
+ rpc :UpdatePlayer, UpdatePlayerRequest, EmptyResponse
42
+ end
43
+
44
+ Stub = Service.rpc_stub_class
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,12 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: conreality/rpc/model.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ Google::Protobuf::DescriptorPool.generated_pool.build do
7
+ end
8
+
9
+ module Conreality
10
+ module RPC
11
+ end
12
+ end
@@ -0,0 +1,129 @@
1
+ # This is free and unencumbered software released into the public domain.
2
+
3
+ require_relative 'event'
4
+ require_relative 'game'
5
+ require_relative 'message'
6
+
7
+ module Conreality
8
+ ##
9
+ # An authenticated session.
10
+ class Session
11
+ ##
12
+ # The client connection this session belongs to.
13
+ #
14
+ # @return [Client]
15
+ attr_reader :client
16
+
17
+ ##
18
+ # The session ID.
19
+ #
20
+ # @return [Integer]
21
+ attr_reader :id
22
+
23
+ ##
24
+ # @param client [Client]
25
+ # @param id [Integer]
26
+ def initialize(client, id)
27
+ @client, @id = client, id.to_i
28
+ end
29
+
30
+ ##
31
+ # Returns a developer-friendly representation of this session.
32
+ #
33
+ # @return [String]
34
+ def inspect
35
+ sprintf("#<%s:%#0x>", self.class.name, self.__id__)
36
+ end
37
+
38
+ ##
39
+ # Invokes the session-scoped `Ping` method on the server.
40
+ #
41
+ # @return [void]
42
+ def ping
43
+ @client.rpc_session.ping(RPC::PingRequest.new)
44
+ end
45
+
46
+ ##
47
+ # Invokes the session-scoped `SendEvent` method on the server.
48
+ #
49
+ # @param [String, #to_s] predicate
50
+ # @param [Object] subject
51
+ # @param [Object] object
52
+ # @return [Event]
53
+ def send_event(predicate, subject, object)
54
+ response = @client.rpc_session.send_event(
55
+ RPC::SendEventRequest.new(
56
+ session_id: @id,
57
+ predicate: predicate,
58
+ subject: subject,
59
+ object: object,
60
+ )
61
+ )
62
+ Event.new(self, response.id)
63
+ end
64
+
65
+ ##
66
+ # Invokes the session-scoped `SendMessage` method on the server.
67
+ #
68
+ # @param [String, #to_s] text
69
+ # @return [Message]
70
+ def send_message(text)
71
+ response = @client.rpc_session.send_message(
72
+ RPC::SendMessageRequest.new(
73
+ session_id: @id,
74
+ text: text.to_s,
75
+ )
76
+ )
77
+ Message.new(self, response.id)
78
+ end
79
+
80
+ ##
81
+ # Invokes the session-scoped `UpdatePlayer` method on the server.
82
+ #
83
+ # @return [void]
84
+ def update_player()
85
+ @client.rpc_session.update_player(
86
+ RPC::UpdatePlayerRequest.new(
87
+ session_id: @id,
88
+ )
89
+ )
90
+ end
91
+
92
+ ##
93
+ # Terminates this session.
94
+ #
95
+ # @return [void]
96
+ def logout!
97
+ # TODO
98
+ @client = nil
99
+ end
100
+
101
+ ##
102
+ # TODO
103
+ #
104
+ # @return [Game]
105
+ def game
106
+ Game.new(self)
107
+ end
108
+
109
+ # @!group Action execution
110
+
111
+ ##
112
+ # @yield [action]
113
+ # @yieldparam action [Action]
114
+ # @yieldreturn [void]
115
+ # @return [void]
116
+ def _execute(&block)
117
+ action = Action.new(self)
118
+ if @client.connection.transaction_status.zero?
119
+ # not yet in transaction scope
120
+ @client.connection.transaction { |_| block.call(action) }
121
+ else
122
+ # already in transaction scope
123
+ block.call(action)
124
+ end
125
+ end
126
+
127
+ # @!endgroup
128
+ end # Session
129
+ end # Conreality
@@ -0,0 +1,74 @@
1
+ # This is free and unencumbered software released into the public domain.
2
+
3
+ module Conreality
4
+ ##
5
+ # Represents a Conreality theater of operations.
6
+ class Theater #< Database::Row
7
+ TABLE = :theater
8
+ KEY = :uuid
9
+
10
+ ##
11
+ # The theater's unique identifier.
12
+ #
13
+ # @return [String]
14
+ attr_reader :uuid
15
+
16
+ ##
17
+ # The theater's designated label.
18
+ #
19
+ # @return [String]
20
+ attr_accessor :label
21
+
22
+ ##
23
+ # The theater's origin location (as GPS coordinates).
24
+ #
25
+ # @return [?]
26
+ attr_accessor :location
27
+
28
+ ##
29
+ # @param session [Session]
30
+ # @param uuid [#to_s]
31
+ def initialize(session, uuid)
32
+ super(session)
33
+ @uuid = uuid.to_s
34
+ end
35
+
36
+ ##
37
+ # Returns a developer-friendly representation of this theater.
38
+ #
39
+ # @return [String]
40
+ def inspect
41
+ sprintf("#<%s:%#0x(uuid: %s)>", self.class.name, self.__id__, @uuid)
42
+ end
43
+
44
+ ##
45
+ # @todo
46
+ def each_object(&block)
47
+ # TODO
48
+ end
49
+
50
+ ##
51
+ # @todo
52
+ def each_asset(&block)
53
+ # TODO
54
+ end
55
+
56
+ ##
57
+ # @todo
58
+ def each_camera(&block)
59
+ # TODO
60
+ end
61
+
62
+ ##
63
+ # @todo
64
+ def each_player(&block)
65
+ # TODO
66
+ end
67
+
68
+ ##
69
+ # @todo
70
+ def each_target(&block)
71
+ # TODO
72
+ end
73
+ end # Theater
74
+ end # Conreality
@@ -0,0 +1,21 @@
1
+ # This is free and unencumbered software released into the public domain.
2
+
3
+ module Conreality
4
+ module VERSION
5
+ FILE = File.expand_path('../../VERSION', __dir__).freeze
6
+ STRING = File.read(FILE).chomp.freeze
7
+ MAJOR, MINOR, TINY, EXTRA = STRING.split('.').map(&:to_i).freeze
8
+
9
+ ##
10
+ # @return [String]
11
+ def self.to_s() STRING end
12
+
13
+ ##
14
+ # @return [String]
15
+ def self.to_str() STRING end
16
+
17
+ ##
18
+ # @return [Array(Integer, Integer, Integer)]
19
+ def self.to_a() [MAJOR, MINOR, TINY].freeze end
20
+ end # VERSION
21
+ end # Conreality
metadata ADDED
@@ -0,0 +1,164 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: conreality
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ platform: ruby
6
+ authors:
7
+ - Conreality.org
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-10-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 12.3.1
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 12.3.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '3.8'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '3.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: yard
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0.9'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0.9'
55
+ - !ruby/object:Gem::Dependency
56
+ name: drylib
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: grpc
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.15'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.15'
83
+ - !ruby/object:Gem::Dependency
84
+ name: uuid
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.3'
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: 2.3.9
93
+ type: :runtime
94
+ prerelease: false
95
+ version_requirements: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - "~>"
98
+ - !ruby/object:Gem::Version
99
+ version: '2.3'
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: 2.3.9
103
+ description: Conreality Software Development Kit (SDK) for Ruby.
104
+ email: conreality@googlegroups.com
105
+ executables: []
106
+ extensions: []
107
+ extra_rdoc_files: []
108
+ files:
109
+ - AUTHORS
110
+ - CREDITS.rst
111
+ - README
112
+ - UNLICENSE
113
+ - VERSION
114
+ - lib/conreality.rb
115
+ - lib/conreality/action.rb
116
+ - lib/conreality/asset.rb
117
+ - lib/conreality/binary.rb
118
+ - lib/conreality/camera.rb
119
+ - lib/conreality/client.rb
120
+ - lib/conreality/event.rb
121
+ - lib/conreality/game.rb
122
+ - lib/conreality/message.rb
123
+ - lib/conreality/object.rb
124
+ - lib/conreality/player.rb
125
+ - lib/conreality/rpc.rb
126
+ - lib/conreality/rpc/common_pb.rb
127
+ - lib/conreality/rpc/master_pb.rb
128
+ - lib/conreality/rpc/master_services_pb.rb
129
+ - lib/conreality/rpc/model_pb.rb
130
+ - lib/conreality/session.rb
131
+ - lib/conreality/theater.rb
132
+ - lib/conreality/version.rb
133
+ homepage: https://sdk.conreality.org/ruby/
134
+ licenses:
135
+ - Unlicense
136
+ metadata:
137
+ bug_tracker_uri: https://github.com/conreality/conreality.rb/issues
138
+ changelog_uri: https://github.com/conreality/conreality.rb/blob/master/CHANGES.rst
139
+ documentation_uri: https://www.rubydoc.info/github/conreality/conreality.rb/master
140
+ homepage_uri: https://sdk.conreality.org/ruby/
141
+ mailing_list_uri: https://groups.google.com/forum/#!forum/conreality
142
+ source_code_uri: https://github.com/conreality/conreality.rb
143
+ wiki_uri: https://wiki.conreality.org/Ruby
144
+ post_install_message:
145
+ rdoc_options: []
146
+ require_paths:
147
+ - lib
148
+ required_ruby_version: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: 2.5.1
153
+ required_rubygems_version: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ version: 2.7.6
158
+ requirements: []
159
+ rubyforge_project:
160
+ rubygems_version: 2.7.6
161
+ signing_key:
162
+ specification_version: 4
163
+ summary: Conreality Software Development Kit (SDK) for Ruby.
164
+ test_files: []