UNPKG

@csegames/camelot-unchained

Version:

Camelot Unchained Client Library

60 lines (59 loc) 2.27 kB
"use strict"; /* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ Object.defineProperty(exports, "__esModule", { value: true }); var client_1 = require("../../core/client"); var SignalRHub_1 = require("../SignalRHub"); // UI EVENT NAMES exports.WARBAND_EVENTS_JOINED = 'warbands/joined'; exports.WARBAND_EVENTS_UPDATE = 'warbands/update'; exports.WARBAND_EVENTS_QUIT = 'warbands/quit'; exports.WARBAND_EVENTS_ABANDONED = 'warbands/abandoned'; exports.WARBAND_EVENTS_MEMBERJOINED = 'warbands/memberJoined'; exports.WARBAND_EVENTS_MEMBERUPDATE = 'warbands/memberUpdate'; exports.WARBAND_EVENTS_MEMBERREMOVED = 'warbands/memberRemoved'; exports.WARBAND_EVENTS_INVITERECEIVED = 'warbands/inviteReceived'; var warbandEventsMap = [{ receive: 'warbandJoined', send: exports.WARBAND_EVENTS_JOINED }, { receive: 'warbandUpdate', send: exports.WARBAND_EVENTS_UPDATE }, { receive: 'warbandQuit', send: exports.WARBAND_EVENTS_QUIT }, { receive: 'warbandAbandoned', send: exports.WARBAND_EVENTS_ABANDONED }, { receive: 'warbandMemberJoined', send: exports.WARBAND_EVENTS_MEMBERJOINED }, { receive: 'warbandMemberUpdate', send: exports.WARBAND_EVENTS_MEMBERUPDATE }, { receive: 'warbandMemberRemoved', send: exports.WARBAND_EVENTS_MEMBERREMOVED }, { receive: 'warbandInviteReceived', send: exports.WARBAND_EVENTS_INVITERECEIVED }]; exports.warbandsHub = new SignalRHub_1.SignalRHub('warbandsHub', warbandEventsMap, { debug: client_1.default.debug }); exports.warbandsHub.onConnected = function (hub) { hub.invoke('identify', client_1.default.loginToken, client_1.default.shardID, client_1.default.characterID).done(function (success) { if (!success) { if (client_1.default.debug) console.warn('WarbandsHub identify failed.'); // Try again! setTimeout(function () { return hub.onConnected(hub); }, 5000); return; } // invalidate to force a resend of all data to this client hub.invoke('invalidate'); }); }; exports.default = exports.warbandsHub;