Online Buddy Variable or Offline Buddy Variables

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

User avatar
hoangdoanh
Posts: 253
Joined: 21 Jun 2013, 04:54
Location: Vietnam

Online Buddy Variable or Offline Buddy Variables

Postby hoangdoanh » 10 Sep 2013, 08:35

Hi all

I write new class that implements BuddyStorage interface to change the way stores buddylist from files-based to database.

But I found something strange in the result :
In retrieval of buddy variables for one buddy I get one buddy variable for key "$key1". But it is not online, and offline variables, because the result always be empty in result of getOnlineVariables and getOfflineVariables functions.

Code: Select all

            NSArray *   array=[buddy getOfflineVariables];
           
            SFSBuddyVariable *  var ;

            //Here [array count]=0 ;
            for(int j=0;j<[array count];j++)
            {
                var=[array objectAtIndex:j];
                NSLog(@" value = %@", [var getStringValue]);
               
            }
           
            array=[buddy getOnlineVariables];
           
            //Here [array count]=0 ;
            for(int j=0;j<[array count];j++)
            {
                var=[array objectAtIndex:j];
                NSLog(@" value = %@", [var getStringValue]);
               
            }

            //Here I get value of variable for key $key1.
            {
                var=[buddy getVariable:@"$key1"];
                NSLog(@"key =  value = %@", [var getStringValue]);
               

            }


So I found variable that is not online, and offline ?

Could you please explain me why this happened .

Thank you very much !


Doanh
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Online Buddy Variable or Offline Buddy Variables

Postby rjgtav » 10 Sep 2013, 09:10

Hi,

How are you setting the "$key1" variable? And when? As it has the $ prefix, it should be an offline BuddyVariable.
And from which client are you trying to retrieve it? The client that owns that variables? A different client?

If you, on the BuddyStorage class, trace the variables that you've just loaded, does it show any variable?
And how's your BuddyStorage class? Are you using a Database for storing the variables?
Please provide further details

Cheers
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
User avatar
hoangdoanh
Posts: 253
Joined: 21 Jun 2013, 04:54
Location: Vietnam

Re: Online Buddy Variable or Offline Buddy Variables

Postby hoangdoanh » 10 Sep 2013, 09:23

Hi
I am answering you line by line

How are you setting the "$key1" variable? And when?

I use mysql database to store variables( it has 3 columns : buddy_user_id | buddy_key |buddy_value). And for testing purpose. I manually set this value directly in database.

As it has the $ prefix, it should be an offline BuddyVariable.


I agree !
And from which client are you trying to retrieve it?

I am retrieve it on iphone/ ios.

The client that owns that variables? A different client?

I have only on client is ios simulator.

If you, on the BuddyStorage class, trace the variables that you've just loaded, does it show any variable?

Yes, In server-side by tracing, I see that there are 2 offline variables clearly.

And how's your BuddyStorage class? Are you using a Database for storing the variables?

Yes, It is right.

I can paste here my code for refference :

Code: Select all

   public List<BuddyVariable> getOfflineVariables(String buddyName) throws IOException
   {
      
      List<BuddyVariable> offlineBuddyVars =  new ArrayList<BuddyVariable>();
      
      this.getConnection();
      String queryString="SELECT buddy_key, buddy_value FROM poker_buddy_variable WHERE buddy_user_id='?0'";
      queryString=TPKDatabase.SetQueryString(0, queryString, buddyName);
      //TPKObjectFactory.getSupporter().logToClient(queryString);
      
      try{
         PreparedStatement sql   =   conn.prepareStatement(queryString);
         ResultSet   resultSet   =   sql.executeQuery();
         BuddyVariable buddyVar    = null ;
         while(resultSet.next())
         {
            buddyVar=new SFSBuddyVariable(resultSet.getString(1),resultSet.getString(2));
            
            offlineBuddyVars.add(buddyVar);
         }
      }
      catch(SQLException ex)
      {
         TPKObjectFactory.getSupporter().logToClient("error get offline varialbe infor="+ex.toString());
      }
      
      return offlineBuddyVars ;
   }


Kind regards,
Doanh
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Online Buddy Variable or Offline Buddy Variables

Postby Lapo » 10 Sep 2013, 09:38

Hi Doanh,
since you are using a custom persistence class it's difficult for us to determine where the problem could be. The loading and saving of the persistent variables is dependent on the storage class, so it is possible that there's a bug in your persistence class.

To confirm this hypothesis I would recommend to momentarily swap back to the default BuddyList storage system provided by SmartFoxServer and see if the same problem appears. It shouldn't, but if it does we'll try to reproduce the problem over here.

What iOS API version are you using?
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
hoangdoanh
Posts: 253
Joined: 21 Jun 2013, 04:54
Location: Vietnam

Re: Online Buddy Variable or Offline Buddy Variables

Postby hoangdoanh » 10 Sep 2013, 09:47

Hi lapo

My ios version is 6.1

Ok, as you advice, I will back to default storage system, test and give you information .

Kind regards,
Doanh
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Online Buddy Variable or Offline Buddy Variables

Postby Lapo » 10 Sep 2013, 10:02

Actually I was asking about the version of the SmartFox client API for iOS :)
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
hoangdoanh
Posts: 253
Joined: 21 Jun 2013, 04:54
Location: Vietnam

Re: Online Buddy Variable or Offline Buddy Variables

Postby hoangdoanh » 10 Sep 2013, 10:08

Ah ok

Its version is 1.1.5 . Is it Okay ?

Kind regards,
Doanh
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Online Buddy Variable or Offline Buddy Variables

Postby Lapo » 10 Sep 2013, 14:35

Yes thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
hoangdoanh
Posts: 253
Joined: 21 Jun 2013, 04:54
Location: Vietnam

Re: Online Buddy Variable or Offline Buddy Variables

Postby hoangdoanh » 12 Sep 2013, 03:13

Hi Lapo

Before back to standard storage, I am checking type of buddy variables, and it is offline. In reading buddy variables I will not use getOfflineVariables to get all variables, I will access them by key. And Saving offline variables is working fine to me now. So at this moment current ability satisfy my need. And I don't need to spend time more for this.

Thank you

Kind regards,
Doanh
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Online Buddy Variable or Offline Buddy Variables

Postby Lapo » 12 Sep 2013, 07:08

Ok, thanks.
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: DonaldVed and 114 guests