@@ -11,36 +11,14 @@ import Alamofire
11
11
12
12
class BonNetwork : NSObject {
13
13
14
- var alamoFireManager = Alamofire . Manager. sharedInstance
15
-
16
- // let configuration = NSURLSessionConfiguration.defaultSessionConfiguration()
17
- // configuration.timeoutIntervalForRequest = 4 // seconds
18
- // configuration.timeoutIntervalForResource = 4
19
- // self.alamoFireManager = Alamofire.Manager(configuration: configuration)
20
- // let center = NSNotificationCenter.defaultCenter()
21
- // var alamoFireManager : Alamofire.Manager?
22
- //
23
- // var configuration = NSURLSessionConfiguration.defaultSessionConfiguration()
24
- // //configuration.timeoutIntervalForRequest = 4 // seconds
25
- // configuration.timeoutIntervalForResource = 4
26
- // self.alamoFireManager = Alamofire.Manager(configuration: configuration)
27
-
28
- // var alamofireManager : Manager?
29
- // // 设置请求的超时时间
30
- // let config = NSURLSessionConfiguration.defaultSessionConfiguration()
31
- // config.timeoutIntervalForRequest = 5 // 秒
32
- // self.alamofireManager = Manager(configuration: config)
33
-
34
14
/**
35
- * login function
36
- * url : url
37
- * params : JSON
38
- * success : Request success callback function
15
+ * post function
16
+ * parameters: JSON
17
+ * success: Request success callback function
39
18
*/
40
19
41
20
static func post( parameters: [ String : AnyObject ] ? , success: ( value: String ) -> Void ) {
42
21
43
- //UIApplication.sharedApplication().networkActivityIndicatorVisible = true
44
22
Alamofire . request ( . POST, BIT . URL. AuthActionURL, parameters: parameters)
45
23
. responseString { response in
46
24
switch response. result {
@@ -55,10 +33,15 @@ class BonNetwork: NSObject {
55
33
56
34
}
57
35
36
+ /**
37
+ * post function
38
+ * parameters: JSON
39
+ * success: Request success callback function
40
+ * fail: Request fail callback function
41
+ */
58
42
59
43
static func post( parameters: [ String : AnyObject ] ? , success: ( value: String ) -> Void , fail: ( error : Any ) -> Void ) {
60
44
61
- //UIApplication.sharedApplication().networkActivityIndicatorVisible = true
62
45
Alamofire . request ( . POST, BIT . URL. AuthActionURL, parameters: parameters)
63
46
. responseString { response in
64
47
switch response. result {
@@ -74,61 +57,7 @@ class BonNetwork: NSObject {
74
57
}
75
58
76
59
77
- /**
78
- * login function
79
- * url : url
80
- * params : JSON
81
- * success : Request success callback function
82
- */
83
-
84
- static func login( parameters: [ String : AnyObject ] ? , success: ( value: String ) -> Void ) {
85
-
86
- //UIApplication.sharedApplication().networkActivityIndicatorVisible = true
87
- Alamofire . request ( . POST, BIT . URL. DoLoginURL, parameters: parameters)
88
- . responseString { response in
89
- switch response. result {
90
- case . Success( let value) :
91
- success ( value: value)
92
-
93
- case . Failure( let error) :
94
- print ( " Request failed with error: \( error) " )
95
- }
96
- }
97
-
98
-
99
- }
100
-
101
-
102
- /**
103
- * keepLive function
104
- * parameters : JSON
105
- * success : Request success callback function
106
- */
107
-
108
- static func keepLive( parameters: [ String : AnyObject ] ? , success: ( value: String ) -> Void ) {
109
-
110
- Alamofire . request ( . POST, BIT . URL. KeepLiveURL, parameters: parameters)
111
- . responseString { response in
112
- switch response. result {
113
- case . Success( let value) :
114
- success ( value: value)
115
-
116
- case . Failure( let error) :
117
- print ( " Request failed with error: \( error) " )
118
- }
119
-
120
- }
121
-
122
- }
123
-
124
- /**
125
- * logout function
126
- * url : url
127
- * params : JSON
128
- * success : Request success callback function
129
- */
130
-
131
- func logout( ) {
60
+ static func logout( ) {
132
61
133
62
let parameters = [
134
63
" action " : " auto_logout "
@@ -137,74 +66,6 @@ class BonNetwork: NSObject {
137
66
}
138
67
}
139
68
140
- // FIXME: It doesn't work well
141
-
142
- /**
143
- * forceLogout function
144
- * url : url
145
- * params : JSON
146
- * success : Request success callback function
147
- */
148
-
149
- static func forceLogout( parameters : [ String : AnyObject ] ? , success : ( value : String ) -> Void ) {
150
-
151
- Alamofire . request ( . POST, BIT . URL. ForceLogoutURL, parameters: parameters)
152
- . responseString { response in
153
- switch response. result {
154
- case . Success( let value) :
155
- success ( value: value)
156
-
157
- case . Failure( let error) :
158
- print ( " Request failed with error: \( error) " )
159
- }
160
- }
161
- }
162
-
163
-
164
- // MARK: Get user balance, show it on another view
165
-
166
- /**
167
- * getBalance function
168
- * url : url
169
- * params : JSON
170
- * success : Request success callback function
171
- */
172
-
173
- static func getBalance( parameters : [ String : AnyObject ] ? , success : ( value : AnyObject ? ) -> Void ) {
174
-
175
- Alamofire . request ( . GET, BIT . URL. UserOnlineURL, parameters: parameters)
176
- . responseJSON { response in
177
- switch response. result {
178
- case . Success( let value) :
179
- success ( value: value)
180
-
181
- case . Failure( let error) :
182
- print ( " Request failed with error: \( error) " )
183
- }
184
- }
185
- }
186
-
187
- /**
188
- * getLoginState function
189
- * url : url
190
- * params : JSON
191
- * success : Request success callback function
192
- */
193
-
194
-
195
- static func getOnlineInfo( success: ( value : String ) -> Void ) {
196
-
197
- let parameters = [
198
- " action " : " get_online_info "
199
- ]
200
-
201
- post ( parameters) { ( value) in
202
- success ( value: value)
203
- }
204
-
205
- }
206
-
207
-
208
69
static func updateLoginState( ) {
209
70
210
71
let parameters = [
0 commit comments