diff --git a/lib_client_onNotification.js.html b/lib_client_onNotification.js.html index fea2812e8..add900279 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 9f25c0752..b47099383 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 01581ca17..fa65bf771 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