wsocket-io 0.1.0 → 0.2.0
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 +4 -4
- data/README.md +14 -1
- data/lib/wsocket_io.rb +34 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 364f60c0ddccc011ab9fdf5d1e70c0300606b4b725cf62a6517788d7e6235c44
|
|
4
|
+
data.tar.gz: 03be3ff5feb44b1eb4e19e57ec431fc62562f84e99a255e17dd785db3814f15f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cf9863ab333af49f73531870b84492e833654e2880955119b2d544673bfb694753e0f097b1f4e15ebf0f380e03c854593ec9a7cd5161f380034c2e79fcc85e0d
|
|
7
|
+
data.tar.gz: 4ddaa4557efe1b903300b09b098cbcfaf0327e9cb93d4c8a44bd5dd766ae2b4674d8bf962331733dd303586dfc8e5d4b98e53f3a321528f9d876024f2993f0ac
|
data/README.md
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
# wSocket SDK for Ruby
|
|
2
2
|
|
|
3
|
-
Official Ruby SDK for wSocket — realtime pub/sub, presence, history, and push notifications.
|
|
3
|
+
Official Ruby SDK for [wSocket](https://wsocket.io) — realtime pub/sub, presence, history, and push notifications.
|
|
4
|
+
|
|
5
|
+
[](https://rubygems.org/gems/wsocket-io)
|
|
6
|
+
[](LICENSE)
|
|
4
7
|
|
|
5
8
|
## Installation
|
|
6
9
|
|
|
@@ -94,6 +97,16 @@ push.send_to_member('user-123', payload: {
|
|
|
94
97
|
|
|
95
98
|
# Broadcast
|
|
96
99
|
push.broadcast(payload: { title: 'Announcement', body: 'Server update' })
|
|
100
|
+
|
|
101
|
+
# Channel targeting
|
|
102
|
+
push.add_channel('subscription-id', 'alerts')
|
|
103
|
+
push.remove_channel('subscription-id', 'alerts')
|
|
104
|
+
|
|
105
|
+
# VAPID key
|
|
106
|
+
vapid_key = push.get_vapid_key
|
|
107
|
+
|
|
108
|
+
# List subscriptions
|
|
109
|
+
subs = push.list_subscriptions('user-123')
|
|
97
110
|
```
|
|
98
111
|
|
|
99
112
|
## Requirements
|
data/lib/wsocket_io.rb
CHANGED
|
@@ -212,6 +212,40 @@ module WSocketIO
|
|
|
212
212
|
Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') { |http| http.request(req) }
|
|
213
213
|
end
|
|
214
214
|
|
|
215
|
+
def delete_subscription(subscription_id)
|
|
216
|
+
uri = URI("#{@base_url}/api/push/subscriptions/#{subscription_id}")
|
|
217
|
+
req = Net::HTTP::Delete.new(uri, headers)
|
|
218
|
+
Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') { |http| http.request(req) }
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
def add_channel(member_id, channel:)
|
|
222
|
+
post('channels/add', { memberId: member_id, channel: channel })
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
def remove_channel(member_id, channel:)
|
|
226
|
+
post('channels/remove', { memberId: member_id, channel: channel })
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
def get_vapid_key
|
|
230
|
+
uri = URI("#{@base_url}/api/push/vapid-key")
|
|
231
|
+
req = Net::HTTP::Get.new(uri, headers)
|
|
232
|
+
resp = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') { |http| http.request(req) }
|
|
233
|
+
data = JSON.parse(resp.body)
|
|
234
|
+
data['vapidPublicKey']
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
def list_subscriptions(member_id: nil, platform: nil, limit: nil)
|
|
238
|
+
params = []
|
|
239
|
+
params << "memberId=#{member_id}" if member_id
|
|
240
|
+
params << "platform=#{platform}" if platform
|
|
241
|
+
params << "limit=#{limit}" if limit
|
|
242
|
+
qs = params.any? ? "?#{params.join('&')}" : ''
|
|
243
|
+
uri = URI("#{@base_url}/api/push/subscriptions#{qs}")
|
|
244
|
+
req = Net::HTTP::Get.new(uri, headers)
|
|
245
|
+
resp = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') { |http| http.request(req) }
|
|
246
|
+
JSON.parse(resp.body)
|
|
247
|
+
end
|
|
248
|
+
|
|
215
249
|
private
|
|
216
250
|
|
|
217
251
|
def headers
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: wsocket-io
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- wSocket
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-03-
|
|
11
|
+
date: 2026-03-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: websocket-client-simple
|