problem|| Problem using the onBuddyPermissionRequest function

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

ransaymour
Posts: 27
Joined: 20 Jun 2016, 18:30

problem|| Problem using the onBuddyPermissionRequest function

Postby ransaymour » 27 Apr 2017, 22:45

Server version: 1.6.19
API version : I think it's 1.5.2
Server side code :

Code: Select all

   
   if (cmd == "buddylistR")
   {
           var userVar = user.getVariable("char_name")
               var char_name =  userVar.getValue()
      var name_id = params["name_id"]
      var tiponum = params["tiponum"]
      var buddy = params["buddy"]
       var tiponum_id = params["tiponum_id"]
    _server.requestAddBuddyPermission(user, buddy, char_name)
   
   }

Client side code:

Code: Select all

smartfox.onBuddyPermissionRequest = function(sender, message) {
   xxx = sender;
   bud_windows[xxx] = _root.attachMovie("buddy_req_got_mc", "buddy_req_got_mc"+xxx, _root.getNextHighestDepth());
   bud_windows[xxx].name_txt.text = message;
   bud_windows[xxx].idd = sender.getId();
   bud_windows[xxx].invited_b_user = sender.getId;
   bud_windows[xxx].invited_b_user_name = sender;
   bud_windows[xxx].char_name = message;
};


The problem:
The message sent is: undefined,
Instead of the defined message
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: problem|| Problem using the onBuddyPermissionRequest function

Postby Lapo » 28 Apr 2017, 08:29

Hi,
are you sure the data sent as message (char_name) is actually a valid string?

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
ransaymour
Posts: 27
Joined: 20 Jun 2016, 18:30

Re: problem|| Problem using the onBuddyPermissionRequest function

Postby ransaymour » 29 Apr 2017, 11:46

Lapo wrote:Hi,
are you sure the data sent as message (char_name) is actually a valid string?

Thanks


Yes, I also added trace(char_name) to check And it works but it is not sent to the client side with the function.

you can check ?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: problem|| Problem using the onBuddyPermissionRequest function

Postby Lapo » 02 May 2017, 07:31

Yes, we were able to reproduce the issue.

I can suggest a workaround for this. Open your local AS2 API file and move to line 2732, you should see this code:

Code: Select all

if (xmlObj.txt != undefined)
   message = scope.os.decodeEntities( message )


Replace it with:

Code: Select all

if (xmlObj.txt.value != undefined)
   message = scope.os.decodeEntities(xmlObj.txt.value)


Hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games
ransaymour
Posts: 27
Joined: 20 Jun 2016, 18:30

Re: problem|| Problem using the onBuddyPermissionRequest function

Postby ransaymour » 05 May 2017, 15:41

Lapo wrote:Yes, we were able to reproduce the issue.

I can suggest a workaround for this. Open your local AS2 API file and move to line 2732, you should see this code:

Code: Select all

if (xmlObj.txt != undefined)
   message = scope.os.decodeEntities( message )


Replace it with:

Code: Select all

if (xmlObj.txt.value != undefined)
   message = scope.os.decodeEntities(xmlObj.txt.value)


Hope it helps




Thanks :D I'll try it now, and update you.


~~~ Update ~~~

It works !
this bug be fixed in the next version of the server?
ransaymour
Posts: 27
Joined: 20 Jun 2016, 18:30

Re: problem|| Problem using the onBuddyPermissionRequest function

Postby ransaymour » 06 May 2017, 13:34

I had another problem .. :cry:

Code: Select all

smartfox.onBuddyPermissionRequest = function(sender, message) {
   trace("bPermissionSender: " + sender);
   trace("myName: " + _global.myName);
   xxx = sender;
   bud_windows[xxx] = _root.attachMovie("buddy_req_got_mc", "buddy_req_got_mc"+xxx, _root.getNextHighestDepth());
   bud_windows[xxx].name_txt.text = message;
   bud_windows[xxx].idd = sender.getId();
   bud_windows[xxx].invited_b_user = sender.getId();
   bud_windows[xxx].invited_b_user_name = sender;
   bud_windows[xxx].char_name = message;
};


The problem:
No value is received from "sender.getId()" ..
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: problem|| Problem using the onBuddyPermissionRequest function

Postby Lapo » 08 May 2017, 14:54

Sender is a string, not an object, so there isn't a getId() method directly available.
If you want to lookup the corresponding user object you will need to search it in the Room's local list, provided the user is also in that Room.

hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games
ransaymour
Posts: 27
Joined: 20 Jun 2016, 18:30

Re: problem|| Problem using the onBuddyPermissionRequest function

Postby ransaymour » 08 May 2017, 15:40

Lapo wrote:Sender is a string, not an object, so there isn't a getId() method directly available.
If you want to lookup the corresponding user object you will need to search it in the Room's local list, provided the user is also in that Room.

hope it helps


Can you give me an example code?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: problem|| Problem using the onBuddyPermissionRequest function

Postby Lapo » 08 May 2017, 16:02

To be honest, I don't think you should/would need the id of the user.
Buddy requests can be sent across Rooms, so you won't necessarily be able to "see" the actual user object.

I give you an example.
User Kermit is in Room A
User Piggy is in Room B

Kermit and Piggy are in separate Rooms, therefore they have no knowledge of each other. E.g.: Room A (where Kermit is) doesn't contain Piggy user.

Therefore when Kermit invites Piggy (or any other users) you should not expect to find the local user object of the inviter. That's why you're passed a String in the first place.

You can still try to find the user object in the Room, by accessing Room.getUserList() and going through each User matching his name with the sender parameter. But it's likely you won't find it. (Again, buddy lists work with strings not User object)

Makes sense?
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 29 guests