Skip to content

Communicator

Kysune edited this page Mar 9, 2019 · 10 revisions

Communicator is a class to support EpicGames's XMPP.

Example of use

const { Client } = require('epicgames-client');

let client = new Client({
    email: 'EMAIL',
    password: 'PASSWORD'
});

(async _ => {

	if(!await client.init() || !await client.login())
		throw 'Error while initialize or login process.';

	client.communicator.on('friend:message', async data => {
		let author = await client.getProfile(data.account_id);
		console.log(author.displayName + ': ' + data.message);
	});

	/**
	  * Accepting invitation to Fortnite:
	  */
	
	let Fortnite = require('epicgames-fortnite-client');

	let fn = await eg.runGame(Fortnite);
	
	fn.communicator.on('party:invitation', invitation => {
		invitation.accept();
	});

})();

Notice about whispering to PS/XBOX players

From launcher client (client.communicator in above example) you can whispering only to PC, NS and mobile players. You have to use fortnite client (fn.communicator in above exmaple) to whispering to PC, NS, PS, XBOX and mobile players. Thanks @iXyles for the insight.

Methods

sendMessage(id, message)

  • id [String] - user's id
  • message [String] - message

updateStatus([status=null])

  • status [String|Object|null] (optional) - status is displaying under name on friends list.

sendProbe(jid)

Sending request for presence.

  • jid [JID|String]

Events

Generals

  • disconnected
  • session:started
  • session:ended
  • raw:incoming - Using for debugging, is emited while receiving any data.
  • raw:outgoing - Using for debugging, is emited while sending any data

Friends

  • friends - list of friends, is emited after login.
  • friend:added - is emited while you added new friend and he accepted invitation (and vice versa). Returns Friend object.
  • friend:removed - is emited while your friend has been removed from friends list. Returns Friend object.
  • friend:status - is emited while your friend updated status. Returns Communicator/Status object.
  • friend:request - is emited while someone invited you to friends. Returns FriendRequest object.
  • friend:message is emited while your friend sent you a message. Returns Communicator/FriendMessage object.

Parties

  • party:invitation - is emited while someone invite you to party. Returns Communicator/PartyInvitation object.

  • party:invitation:response - is emited e.g. while someone rejected your invitation. Returns Communicator/PartyInvitationResponse object.

  • party:join:request - is emited while someone wants join into your party. Returns Communicator/PartyJoinRequest object.

  • party:join:approved - is emited while your join request has been approved. Returns Communicator/PartyJoinRequestApproved object.

  • party:join:rejected - is emited while your join request has been rejected. Returns Communicator/PartyJoinRequestRejected object.

  • party:updatepartyconfiguration - is emited while party configuration has been updated. Returns Communication/PartyUpdateConfirmation object.

  • party:member:joined - is emited while someone (or you) join into party. Returns Communicator/PartyMemberJoined object.

  • party:member:exited - is emited while someone (or you) exited party. Returns Communicator/PartyMemberExited object.

  • party:member:promoted - is emited while someone (or you) has been promoted to leader. Returns Communicator/PartyMemberPromoted object.

  • party:member:data - is emited while you join into party. Contains informations about players (e.g. skins). Returns Communicator/PartyMemberData object.

  • party:data - is emited while you join into party. Contains informations about party (e.g. playlist). Returns Communicator/PartyData object.

  • party:query:joinability - is emited while someone wants join into your party. This is query for access to join. Returns Communicator/PartyQueryJoinability object.

  • party:query:joinability:response - this is response for party:query:joinability, is emited while someone answered on your party:query:joinability. Contains informations about permissions to join and reason if you can't join. Returns Communicator/PartyQueryJoinabilityResponse object.

  • party:joinacknowledged - is emited if your party:join:request has been approved. Returns Communicator/PartyJoinAcknowledged object.

  • party:joinacknowledged:response - is emited while you approved party:join:request. Returns Communicator/PartyJoinAcknowledgedResponse object.