From 084032bd73bff93dcb6edb159fbfb7a0ec7fe687 Mon Sep 17 00:00:00 2001 From: Neztore Date: Sat, 18 May 2024 18:44:20 +0000 Subject: [PATCH] deploy: d626e6f49d504f3a2fbfa3cda85b999beee02cc5 --- lib_client_onNotification.js.html | 66 +++++++++++++++---------- lib_privatemessages_getMessages.js.html | 4 +- lib_privatemessages_onMessage.js.html | 11 +++-- 3 files changed, 49 insertions(+), 32 deletions(-) diff --git a/lib_client_onNotification.js.html b/lib_client_onNotification.js.html index fea2812e..add90027 100644 --- a/lib_client_onNotification.js.html +++ b/lib_client_onNotification.js.html @@ -147,7 +147,7 @@

lib/client/onNotification.js

// Dependencies
-const SignalR = require('signalr-client').client
+const signalR = require('@microsoft/signalr')
 const events = require('events')
 
 // Includes
@@ -184,34 +184,50 @@ 

lib/client/onNotification.js

args.jar = { session: args.jar } } const session = getSession({ jar: args.jar }) - const client = new SignalR('wss://realtime.roblox.com/notifications', ['usernotificationhub'], 3, true) // wss for https - client.headers.Cookie = '.ROBLOSECURITY=' + session + ';' - client.on('usernotificationhub', 'notification', function (name, message) { - notifications.emit('data', name, JSON.parse(message)) - }) - notifications.on('close', client.end) - client.serviceHandlers.connectFailed = function (err) { - notifications.emit('error', new Error('Connection failed: ' + err.message)) - if (retries !== -1) { - if (retries > max) { - notifications.emit('close', new Error('Max retries reached')) - } else { - setTimeout(connect, 5000, retries + 1) + let userNotificationConnection = null; + + userNotificationConnection = new signalR.HubConnectionBuilder() + .withUrl('https://realtime-signalr.roblox.com/userhub', { + transport: signalR.HttpTransportType.WebSockets, + skipNegotiation: true, + headers: { + Cookie: '.ROBLOSECURITY=' + session + ';' + } + }) + .build(); + + userNotificationConnection.on('notification', function(name, message) { + notifications.emit('data', name, JSON.parse(message)) + }) + + notifications.on('close', userNotificationConnection.stop) + + userNotificationConnection.disconnected = function (err) { + notifications.emit('error', new Error('Connection failed: ' + err.message)) + if (retries !== -1) { + if (retries > max) { + notifications.emit('close', new Error('Max retries reached')) + } else { + setTimeout(connect, 5000, retries + 1) + } } } - } - client.serviceHandlers.onerror = function (err) { - notifications.emit('error', err) - } - client.serviceHandlers.connected = function (connection) { - notifications.emit('connect', connection) - } - client.serviceHandlers.reconnecting = function () { - setTimeout(connect, 5000, 0) + + userNotificationConnection.error = function (err) { + notifications.emit('error', err) + } + + userNotificationConnection.connected = function(connection) { + notifications.emit('connect', connection) + } + + userNotificationConnection.reconnecting = function () { + setTimeout(connect, 5000, 0) notifications.emit('error', new Error('Lost connection, reconnecting')) return true // Abort reconnection - } - client.start() + } + + userNotificationConnection.start() } connect(-1) return notifications diff --git a/lib_privatemessages_getMessages.js.html b/lib_privatemessages_getMessages.js.html index 9f25c075..b4709938 100644 --- a/lib_privatemessages_getMessages.js.html +++ b/lib_privatemessages_getMessages.js.html @@ -167,13 +167,13 @@

lib/privatemessages/getMessages.js

**/ // Define -function getMessages (jar, token, pageNumber, pageSize, messageTab) { +function getMessages (jar, pageNumber, pageSize, messageTab) { return new Promise((resolve, reject) => { const httpOpt = { url: `//privatemessages.roblox.com/v1/messages?pageNumber=${pageNumber}&pageSize=${pageSize}&messageTab=${messageTab}`, options: { method: 'GET', - jar, + jar: jar, resolveWithFullResponse: true } } diff --git a/lib_privatemessages_onMessage.js.html b/lib_privatemessages_onMessage.js.html index 01581ca1..fa65bf77 100644 --- a/lib_privatemessages_onMessage.js.html +++ b/lib_privatemessages_onMessage.js.html @@ -182,19 +182,20 @@

lib/privatemessages/onMessage.js

const onMessage = new events.EventEmitter() let waitingForRequest = false let latest - getMessages({ jar, messageTab: 'Inbox', pageNumber: 0 }) + getMessages({ jar: jar, messageTab: 'Inbox', pageNumber: 0, pageSize: 1 }) .then(function (initial) { latest = initial.collection[0] ? initial.collection[0].id : 0 - const notifications = onNotification({ jar }) + const notifications = onNotification({ jar: jar }) notifications.on('data', function (name, message) { - if (name === 'NotificationStream' && message.Type === 'NewNotification') { + if (name === 'MessageNotification' && message.Type === 'Created') { if (waitingForRequest) { waitingForRequest = false } else { getMessages({ - jar, + jar: jar, messageTab: 'Inbox', - pageNumber: 0 + pageNumber: 0, + pageSize: 1 }) .then(function (inbox) { const messages = inbox.collection