Jump to content
McKay Development

Recommended Posts

Posted (edited)

Hi, when I use GetPersonas there's a possibility that the requested data would be unavailable. Unfortunately there's no error callback. How can I check it?

I mean something like this:

if (GetPersonas is unavailable)
   // do something...
Edited by iLuk
Posted (edited)

When you are logged out. It happened to my bot when it was reconnecting to Steam after losing the connection.

 

@Edit

Can I check somehow if the bot is logged in?

Edited by iLuk
Posted

I can do something like that:

var partnerName;

client.getPersonas([partnerId], function (persona) {

       partnerName = persona[partnerId].player_name;
});

setTimeout(function(){

if (partnerName == undefined)
       //  data unavailable

},2000);

but is there a better option?

Posted

It also happens when the bot is logged in. How can I edit this function to return error when it fails?

SteamUser.prototype.getPersonas = function(steamids, callback) {
var Flags = Steam.EClientPersonaStateFlag;
var flags = Flags.Status|Flags.PlayerName|Flags.QueryPort|Flags.SourceID|Flags.Presence|
Flags.Metadata|Flags.LastSeen|Flags.ClanInfo|Flags.GameExtraInfo|Flags.GameDataBlob|
Flags.ClanTag|Flags.Facebook;


var ids = steamids.map(function(id) {
if(typeof id === 'string') {
return (new SteamID(id)).getSteamID64();
}


return id.toString();
});


this._send(Steam.EMsg.ClientRequestFriendData, {
"friends": ids,
"persona_state_requested": flags
});


if(callback) {
var output = {};


var self = this;
ids.forEach(function(id) {
self.once('user#' + id, receive);
});


function receive(sid, user) {
var sid64 = sid.getSteamID64();
output[sid64] = user;


var index = ids.indexOf(sid64);
if(index != -1) {
ids.splice(index, 1);
}


if(ids.length === 0) {
callback(output);
}
}
}
};

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...