SFS2X Objective-C API  1.7.13
iOS / macOS / tvOS
SFSBuddy.h
1 //
2 // SFSBuddy.h
3 // SFS2X
4 //
5 // Original development by Infosfer Game Technologies Ltd. | http://www.infosfer.com.
6 //
7 // Maintained and developed by A51 Integrated.
8 // Copyright 2012 A51 Integrated | http://a51integrated.com. All rights reserved.
9 //
10 
11 #import "Buddy.h"
12 
13 /** The SFSBuddy class represent a Buddy in the User's <b>Buddy List</b>.
14 
15  Each Buddy has several properties:
16 
17  - <b>name</b>: the name of the Buddy, corresponds to the User name
18  - <b>nickname</b>: an optional nickname (default = null)
19  - <b>isOnline</b>: whether the Buddy is online in the Buddy system or not
20  - <b>state</b>: a string representing a "state message", such as: <i>Available</i>, <i>Busy</i>...
21  - <b>isBlocked</b>: whether the Buddy is blocked in the User Buddy List
22  - <b>isTemp</b>: a temporary Buddy is not stored in the Buddy List, it will be removed at the end of the session (see below)
23  - <b>variables</b>: the Buddy variables which can be transient or persistent (see below)
24 
25 
26  <b>Online State</b><br/>
27  Any user can decide if they want to be online/off-line as Buddy in the Buddy system. By default a User is online
28  every time he joins the Zone, but the User can also turn off this flag at runtime and disappear from other User's buddy lists.
29  The <b>Online State</b> is persistent and based on a reserved Buddy Variable.
30 
31  <b>Blocked Buddies</b><br/>
32  Buddies that are blocked won't be able to send any messages to the User, also they won't be able to see if the Buddy is online/off-line.
33 
34  <b>Buddy State message</b><br/>
35  The state message represents a typical IM Buddy state such as Available, Busy etc...
36  By default the system already provides 3 default states: <b>Available</b>, <b>Away</b>, <b>Occupied</b> which can be changed or enriched at any time
37  The state message is based on a reserved Buddy Variable.
38 
39  <b>Temp Buddy</b><br/>
40  A temporary Buddy is added to the User List when another User adds me to his Buddy List.
41  This way we can see each others and exchange messages.
42  If I don't add the User as Buddy in my list the User will remain temporary and it won't be persisted.
43 
44  <b>Variables</b><br/>
45  Buddy Variables enable each Buddy to show/send updates for specific informations to each User that has the Buddy in the list.
46  For example one could send real-time updates on his last activity (ala Twitter) or post the title of the song he's listening right now, scores,
47  rankings and whatnot.
48 
49  */
50 @interface SFSBuddy : NSObject <Buddy>
51 {
52 @protected
53  NSInteger _id;
54  NSString *_name;
55  BOOL _isBlocked;
56  NSMutableDictionary *_variables;
57  BOOL _isTemp;
58 }
59 /**
60  The name of the Buddy
61  */
62 @property (nonatomic, strong) NSString *name;
63 /**
64  Obtain a list of BuddyVariables.
65  Please note that by convention any variable whose name starts with the dollar sign ($)
66  will be regarded as persistent and stored locally by the server.
67 
68  These variables are also referred to as "offline variables" because they are available
69  to other Users even when the Buddy is offline.
70 
71  @see SFSBuddyVariable
72  @see SetBuddyVariablesRequest
73  */
74 @property (nonatomic, strong) NSArray *variables;
75 /**
76  The id of the Buddy
77  The id corresponds to the current id of the User in the system
78  */
79 @property (nonatomic, assign) NSInteger id;
80 /**
81  Return true if the Buddy is blocked in the current Users' BuddyList
82 
83  @see BlockBuddyRequest
84  */
85 @property (nonatomic, assign) BOOL isBlocked;
86 /**
87  Return true if the Buddy is temporary (not persistent)
88  */
89 @property (nonatomic, assign) BOOL isTemp;
90 
91 /**
92  Return true if the User is online in the BuddyList system
93  The value is stored in a reserved Buddy Variable
94 
95  @see GoOnlineRequest
96  @see ReservedBuddyVariables
97  */
98 @property (readonly) BOOL isOnline;
99 /**
100  An optional Buddy nickname
101  The value is stored in a reserved Buddy Variable
102 
103  @see ReservedBuddyVariables
104  */
105 @property (weak, readonly) NSString *nickName;
106 /**
107  The current Buddy custom state (e.g. "Available", "Busy", etc...)
108  The value is stored in a reserved Buddy Variable
109 
110  @see ReservedBuddyVariables
111  */
112 @property (weak, readonly) NSString *state;
113 
114 +(id <Buddy>)fromSFSArray:(id <ISFSArray>)arr;
115 -(id)initWithId:(NSInteger)id_ name:(NSString *)name isBlocked:(BOOL)isBlocked isTemp:(BOOL)isTemp;
116 
117 /**
118  Return true if a BuddyVariable with the provided name exists
119  */
120 -(BOOL)containsVariable:(NSString *)varName;
121 /**
122 * Return a list of offline Buddy Variables
123 */
124 -(NSArray *)getOfflineVariables;
125 /**
126  Return a list of non-persistent Buddy Variables
127  */
128 -(NSArray *)getOnlineVariables;
129 /**
130  Get the BuddyVariable with the provided name.
131  nil is returned if not BuddyVariable exists with that name
132  */
133 -(id <BuddyVariable>)getVariable:(NSString *)varName;
134 @end
SFSBuddy
Definition: SFSBuddy.h:50