1+ package restDoaService
2+ {
3+ import flash.net.SharedObject ;
4+
5+ public class RestDoaService
6+ {
7+ internal static const debug_show_results: Boolean = false ;
8+
9+
10+ /**This will take all errors on it*/
11+ public static var eventDispatcher: RestDoaEventDispatcher = new RestDoaEventDispatcher();
12+
13+ /**located server domain*/
14+ internal static var serverDomain: String = null ;
15+
16+ //private static var id_UId:String = "UId",
17+ // id_UIdAuth:String = "UIdAuth";
18+
19+ //private static var _UId:String = '';//"226e4187-4135-4733-bfe2-8fc526d6971c";
20+
21+ //private static var _UIdAuth:String = '';//"29d46f85-1fb5-4ff2-8c36-6d70744eaf45" ;
22+
23+ private static var sharedObject: SharedObject ;
24+
25+ private static function setUpStorage ():void
26+ {
27+ if (sharedObject == null )
28+ {
29+ //trace("♠ Set up shared Object");
30+ sharedObject = SharedObject . getLocal ('restMelkFullCash' ,'/' );
31+ }
32+ }
33+
34+ private static function get (id :String ):String
35+ {
36+ setUpStorage();
37+ var cash: String = sharedObject. data [ id ];
38+ //trace("♠ Load "+id+" from tht shared object");
39+ if (cash == null )
40+ {
41+ return '' ;
42+ }
43+ //trace("♠ Loaded id is : "+cash);
44+ return cash ;
45+ }
46+
47+ private static function set (id :String ,value :String ):void
48+ {
49+ setUpStorage();
50+ //trace("♠ set the "+id+" to "+value);
51+ sharedObject. data [ id ] = value ;
52+ sharedObject. flush ();
53+ }
54+
55+
56+ /*internal static function get UIdAuth():String
57+ {
58+ if(_UIdAuth=='')
59+ {
60+ _UIdAuth = get(id_UIdAuth);
61+ }
62+ return _UIdAuth;
63+ }*/
64+
65+ /*internal static function get UId():String
66+ {
67+ if(_UId=='')
68+ {
69+ _UId = get(id_UId);
70+ }
71+ //trace("♠ Get _UId : "+_UId);
72+ return _UId;
73+ }*/
74+
75+
76+
77+ /*private static function setUIdAuth(value:String):void
78+ {
79+ //trace("♠ set id_UIdAuth from "+_UIdAuth+" To "+value);
80+ if(_UIdAuth!=value)
81+ {
82+ set(id_UIdAuth,value);
83+ _UIdAuth = value;
84+ //trace("♠ done");
85+ }
86+ }*/
87+
88+ /*private static function setUId(value:String):void
89+ {
90+ //trace("♠ set _UId from "+_UId+" To "+value);
91+ if(_UId!=value)
92+ {
93+ set(id_UId,value);
94+ _UId = value;
95+ //trace("♠ done");
96+ }
97+ }*/
98+
99+ internal static function get domain ():String
100+ {
101+ if (serverDomain== null )
102+ {
103+ throw "You Should setUp RestService first!\n Use RestService.setUp() function." ;
104+ }
105+ return serverDomain;
106+ }
107+
108+
109+ public static function setUp (ServerDomain :String ):void
110+ {
111+ if (ServerDomain. charAt (ServerDomain. length - 1 )!= '/' )
112+ {
113+ ServerDomain+= '/' ;
114+ }
115+ serverDomain = ServerDomain ;
116+ //UId;
117+ //UIdAuth;
118+ trace ("Rest service is starts on : " + serverDomain);
119+ }
120+
121+ /**Feal these values from signInViewModel to make user knownAsLoged in
122+ public static function setUid(uId:String,uIdAuth:String):void
123+ {
124+ setUId(uId) ;
125+ setUIdAuth(uIdAuth) ;
126+ trace("User is logged in");
127+ }*/
128+
129+ /*public static function logOut():void
130+ {
131+ setUId('');
132+ setUIdAuth('');
133+ trace("User is logged out");
134+ }*/
135+
136+ /**Returns true if user is logged in.
137+ public static function get isLogedIn():Boolean
138+ {
139+ if(UId=='' || UIdAuth=='')
140+ {
141+ return false ;
142+ }
143+ else
144+ {
145+ return true ;
146+ }
147+ }*/
148+ }
149+ }
0 commit comments