-
Notifications
You must be signed in to change notification settings - Fork 0
/
Network.as
47 lines (39 loc) · 984 Bytes
/
Network.as
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package {
import flash.net.URLVariables
import flash.net.URLRequestMethod
import RestCaller;
import Member;
public class Network {
static public var session_token:String;
static public var me:Member;
public function Network() {
// constructor code
}
public static function login(name:String,password:String,success:Function,fail:Function)
{
var body:URLVariables = new URLVariables();
trace(body)
body.name = name
body.password = password
RestCaller.callWithBody('auth/session',body,URLRequestMethod.POST,
function(param){
var data = JSON.parse(param);
trace(JSON.stringify(data))
me = new Member(data.you);
session_token = data.session_token
if(data.first_connection){
Effector.MovieEffect(new MovieEffect_first_connection());
}
success()
},
function(){
fail()
});
}
public static function logout(){
me = null;
session_token = null;
AutoLogin.removePass();
}
}
}