Created
February 21, 2022 21:07
-
-
Save mikaeldui/f8d4294f7689654bcd7474981d8533c8 to your computer and use it in GitHub Desktop.
League Client WAMP Implementation (minified)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function(e, t, n) { | |
'use strict'; | |
function r(e, t) { | |
if (t && (h('Message QUEUED (' + t.length + ' bytes)'), e._sendQueue.push(JSON.stringify(t))), e._connected) | |
for (; 0 < e._sendQueue.length;) { | |
const t = e._sendQueue.shift(); | |
h('Message SEND'), e._websocket.send(t) | |
} | |
} | |
function i() { | |
return 'xxxxxxxxxxxxxxxx'.replace(/x/g, () => (0 | 36 * Math.random()).toString(36)) | |
} | |
function a(e, t, n) { | |
return function(r) { | |
return delete e._resolvers[t], n(r) | |
} | |
} | |
function o(e) { | |
const t = e._websocket = new _.WebSocket(e._endpoint, ['wamp'], e._options); | |
t.onopen = s.bind(null, e), t.onclose = d.bind(null, e), t.onerror = l.bind(null, e), t.onmessage = u.bind(null, e) | |
} | |
function l() { | |
const e = 'WebSocket event: ERROR'; | |
h(e), console.error(e) | |
} | |
function s() { | |
const e = 'WebSocket event: OPEN'; | |
h(e), console.log(e) | |
} | |
function d(e, t) { | |
const n = 'WebSocket event: CLOSED (' + t.code + ': ' + t.reason + ')'; | |
h(n), e.closed(); | |
const r = t.code === 1006; | |
r ? (o(e), console.log(n)) : console.error(n) | |
} | |
function u(e, t) { | |
h('WebSocket event: MESSAGE (' + t.data.length + ' bytes)'); | |
const n = JSON.parse(t.data), | |
i = n[0], | |
a = n[1], | |
o = n[2]; | |
if (i === f.EVENT) h('received EVENT', a, o), e.publish(o.uri, o); | |
else if (i === f.WELCOME) h('received WELCOME', n.slice(1)), console.log('WAMP Handshake complete'), [e._wampSessionId, e._wampProtocolVersion, e._wampServerIdentity] = n.slice(1), e.ready(), r(e), r(e, [f.SUBSCRIBE, 'OnJsonApiEvent']); | |
else if (i === f.CALLRESULT) { | |
const [, t, r] = n; | |
h('received CALLRESULT', n), e._resolvers[t][0](r) | |
} else if (i === f.CALLERROR) { | |
const [, t, r] = n; | |
h('received CALLERROR', t, r), e._resolvers[t][1](r) | |
} | |
} | |
const p = n(53), | |
c = n(162), | |
f = n(163).WAMP_MESSAGE_IDS, | |
g = n(54); | |
g.enable('wamp:core:error'); | |
const h = g('wamp:core:log'); | |
class _ extends p { | |
constructor(e, t) { | |
h('creating CoreSocket', e), super(), this._websocket = null, this._endpoint = e, this._connected = !1, this._sendQueue = [], this._options = t, this._resolvers = {}, o(this) | |
} | |
call(e, t, n) { | |
const o = i(this); | |
return new Promise((i, l) => { | |
this._resolvers[o] = [a(this, o, i), a(this, o, l)], h('sending CALL message', o, e, t, n), r(this, [f.CALL, o, e, t, n]) | |
}) | |
} | |
close() { | |
super.close(), this._websocket.close() | |
} | |
ready() { | |
this._connected = !0, this._trigger('ready') | |
} | |
closed() { | |
this._connected = !1, this._trigger('closed') | |
} | |
on(e, t) { | |
this._evts = this._evts || new Map; | |
const n = this._evts.get(e) || []; | |
n.push(t), this._evts.set(e, n) | |
} | |
addEventListener() { | |
return this.on.call(this, ...arguments) | |
} | |
removeEventListener(e, t) { | |
this._evts = this._evts || new Map; | |
const n = this._evts.get(e), | |
r = n.indexOf(t); | |
0 <= r && n.splice(r, 1) | |
} | |
_trigger(e, t) { | |
if (this._evts) { | |
const n = this._evts.get(e); | |
n && n.forEach((e) => e.call(null, t)) | |
} | |
} | |
} | |
_.WebSocket = c, e.exports = _ | |
} | |
function(e, t, n) { | |
(function(e) { | |
e.exports = 'undefined' == typeof window ? e.require('../../../node_modules/ws') : window.WebSocket | |
}).call(t, n(74)(e)) | |
} | |
function(e) { | |
'use strict'; | |
const t = {}; | |
e.exports = function(e, n) { | |
let r = t[e]; | |
return r || (r = t[e] = new RegExp('^' + e.replace('*', '.*') + '$')), r.test(n) | |
}, e.exports.matchUrl = e.exports, e.exports.WAMP_MESSAGE_IDS = { | |
WELCOME: 0, | |
PREFIX: 1, | |
CALL: 2, | |
CALLRESULT: 3, | |
CALLERROR: 4, | |
SUBSCRIBE: 5, | |
UNSUBSCRIBE: 6, | |
PUBLISH: 7, | |
EVENT: 8 | |
} | |
} |
Sending a simple JSON object as the only parameter:
[
2,
"123",
"PutLolChatV1Me",
{
"lol": {
"masteryScore": "2000",
"rankedLeagueDivision": "I",
"rankedLeagueQueue": "RANKED_SOLO_5x5",
"rankedLeagueTier": "CHALLENGER"
}
}
]
Using URL: [2, "", "/lol-maps/v1/map/12"]
.
Using HTTP method and URL: [2, "", "GET /lol-perks/v1/pages"]
.
With a simple object as parameter:
[
2,
"",
"PUT /lol-chat/v1/me",
{
"lol": {
"masteryScore": "3000",
"rankedLeagueDivision": "I",
"rankedLeagueQueue": "RANKED_SOLO_5x5",
"rankedLeagueTier": "IRON"
}
}
]
With both a path parameter and request body:
[
2,
"",
"PUT /lol-chat/v1/friends/abcd1234-ab12-ab12-ab12-abcdef123456@eu1.pvp.net",
{
"note": "adc carry"
}
]
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using CALL:
[2, "123", "GetLolMapsV1Maps"]
gets the response:using "" instead of "123":