selfsdk 0.0.203 → 0.0.205
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/selfsdk.rb +8 -0
- data/lib/services/voice.rb +147 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aefa2c3a38cd8b027fb2095affee9bd67b74c1e1c417ffa9e028f656a3d28e34
|
4
|
+
data.tar.gz: 7969b31c5f519a2d9c4a8a098d8862119dbdf4e0aba6dfa71b39dfb7e2d2d437
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f15414f199e776fb0bf7578226c00c8f9c649940fd9ac74d40b177e50a3acca0a48204c8e638a1bf15bc5c09e35a868c60f3833bfd778e8fe13161263d25b11d
|
7
|
+
data.tar.gz: 5e6f46cad290c73094aa2697b63b154a79cd1f54610c7b8051a6b8ebf14e604432fb86ba6b45884aec90ad51c54cb1545bfe5fcb04012c8e6f8160caf7afc44e
|
data/lib/selfsdk.rb
CHANGED
@@ -51,6 +51,8 @@ module SelfSDK
|
|
51
51
|
# @option opts [Bool] :auto_reconnect Automatically reconnects to websocket if connection is lost (defaults to true).
|
52
52
|
# @option opts [Symbol] :env The environment to be used, defaults to ":production".
|
53
53
|
def initialize(app_id, app_key, storage_key, storage_dir, opts = {})
|
54
|
+
app_key = cleanup_key(app_key)
|
55
|
+
|
54
56
|
SelfSDK.logger.debug "syncing ntp times #{SelfSDK::Time.now}"
|
55
57
|
env = opts.fetch(:env, "")
|
56
58
|
|
@@ -132,5 +134,11 @@ module SelfSDK
|
|
132
134
|
MESSAGING_URL
|
133
135
|
end
|
134
136
|
|
137
|
+
def cleanup_key(key)
|
138
|
+
return key unless key.include? '_'
|
139
|
+
|
140
|
+
key.split('_').last
|
141
|
+
end
|
142
|
+
|
135
143
|
end
|
136
144
|
end
|
@@ -0,0 +1,147 @@
|
|
1
|
+
# Copyright 2020 Self Group Ltd. All Rights Reserved.
|
2
|
+
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
require 'self_crypto'
|
6
|
+
require_relative '../chat/file_object'
|
7
|
+
require_relative '../chat/group'
|
8
|
+
require_relative '../chat/message'
|
9
|
+
require_relative "../messages/connection_request"
|
10
|
+
|
11
|
+
module SelfSDK
|
12
|
+
module Services
|
13
|
+
class Voice
|
14
|
+
attr_accessor :app_id
|
15
|
+
|
16
|
+
def initialize(messaging)
|
17
|
+
@messaging = messaging
|
18
|
+
end
|
19
|
+
|
20
|
+
# Sends a chat.voice.setup message to setup a delegated call.
|
21
|
+
def setup(recipient, name, cid)
|
22
|
+
payload = { typ: SelfSDK::Messages::VoiceSetup::MSG_TYPE }
|
23
|
+
payload[:cid] = cid
|
24
|
+
payload[:data] = { name: name }
|
25
|
+
|
26
|
+
send([recipient], payload)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Subscribes to chat.voice.setup messages.
|
30
|
+
def on_setup(&block)
|
31
|
+
@messaging.subscribe :voice_setup do |msg|
|
32
|
+
block.call(msg.payload[:iss], msg.payload[:cid], msg.payload[:data])
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# Sends a chat.voice.start message with the details for starting a call.
|
37
|
+
def start(recipient, cid, call_id, peer_info, data)
|
38
|
+
send([recipient],
|
39
|
+
typ: SelfSDK::Messages::VoiceStart::MSG_TYPE,
|
40
|
+
cid: cid,
|
41
|
+
call_id: call_id,
|
42
|
+
peer_info: peer_info,
|
43
|
+
data: data)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Subscribes to chat.voice.start messages.
|
47
|
+
def on_start(&block)
|
48
|
+
@messaging.subscribe :voice_start do |msg|
|
49
|
+
block.call(msg.payload[:iss],
|
50
|
+
cid: msg.payload[:cid],
|
51
|
+
call_id: msg.payload[:call_id],
|
52
|
+
peer_info: msg.payload[:peer_info],
|
53
|
+
data: msg.payload[:data])
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Sends a chat.voice.accept message accepting a specific call.
|
58
|
+
def accept(recipient, cid, call_id, peer_info)
|
59
|
+
payload = {
|
60
|
+
typ: SelfSDK::Messages::VoiceAccept::MSG_TYPE,
|
61
|
+
cid: cid,
|
62
|
+
call_id: call_id,
|
63
|
+
peer_info: peer_info,
|
64
|
+
}
|
65
|
+
send([recipient], payload)
|
66
|
+
end
|
67
|
+
|
68
|
+
# Subscribes to chat.voice.accept messages.
|
69
|
+
def on_accept(&block)
|
70
|
+
@messaging.subscribe :voice_accept do |msg|
|
71
|
+
block.call(msg.payload[:iss],
|
72
|
+
cid: msg.payload[:cid],
|
73
|
+
call_id: msg.payload[:call_id],
|
74
|
+
peer_info: msg.payload[:peer_info])
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# Sends a chat.voice.accept message finishing the call.
|
79
|
+
def stop(recipient, cid, call_id)
|
80
|
+
payload = {
|
81
|
+
typ: SelfSDK::Messages::VoiceStop::MSG_TYPE,
|
82
|
+
cid: cid,
|
83
|
+
call_id: call_id,
|
84
|
+
}
|
85
|
+
send([recipient], payload)
|
86
|
+
end
|
87
|
+
|
88
|
+
# Subscribes to chat.voice.stop messages.
|
89
|
+
def on_stop(&block)
|
90
|
+
@messaging.subscribe :voice_stop do |msg|
|
91
|
+
block.call(msg.payload[:iss],
|
92
|
+
cid: msg.payload[:cid],
|
93
|
+
call_id: msg.payload[:call_id],
|
94
|
+
peer_info: msg.payload[:peer_info])
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
# Sends a chat.voice.busy message finishing the call.
|
99
|
+
def busy(recipient, cid, call_id)
|
100
|
+
send([recipient],
|
101
|
+
typ: SelfSDK::Messages::VoiceBusy::MSG_TYPE,
|
102
|
+
cid: cid,
|
103
|
+
call_id: call_id)
|
104
|
+
end
|
105
|
+
|
106
|
+
# Subscribes to chat.voice.busy messages.
|
107
|
+
def on_busy(&block)
|
108
|
+
@messaging.subscribe :voice_busy do |msg|
|
109
|
+
block.call(msg.payload[:iss],
|
110
|
+
cid: msg.payload[:cid],
|
111
|
+
call_id: msg.payload[:call_id],
|
112
|
+
peer_info: msg.payload[:peer_info])
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
# Sends a chat.voice.summary message Sending details about the call.
|
117
|
+
def summary(recipient, cid, call_id)
|
118
|
+
send([recipient],
|
119
|
+
typ: SelfSDK::Messages::VoiceSummary::MSG_TYPE,
|
120
|
+
cid: cid,
|
121
|
+
call_id: call_id)
|
122
|
+
end
|
123
|
+
|
124
|
+
# Subscribes to chat.voice.summary messages.
|
125
|
+
def on_summary(&block)
|
126
|
+
@messaging.subscribe :voice_summary do |msg|
|
127
|
+
block.call(msg.payload[:iss],
|
128
|
+
cid: msg.payload[:cid],
|
129
|
+
call_id: msg.payload[:call_id],
|
130
|
+
peer_info: msg.payload[:peer_info])
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
private
|
135
|
+
|
136
|
+
# sends a message to a list of recipients.
|
137
|
+
def send(recipients, body)
|
138
|
+
recipients = [recipients] if recipients.is_a? String
|
139
|
+
m = []
|
140
|
+
recipients.each do |r|
|
141
|
+
m << @messaging.send(r, body)
|
142
|
+
end
|
143
|
+
m
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: selfsdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.205
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aldgate Ventures
|
@@ -392,6 +392,7 @@ files:
|
|
392
392
|
- lib/services/identity.rb
|
393
393
|
- lib/services/messaging.rb
|
394
394
|
- lib/services/requester.rb
|
395
|
+
- lib/services/voice.rb
|
395
396
|
- lib/signature_graph.rb
|
396
397
|
- lib/source_definition.rb
|
397
398
|
- lib/sources.rb
|