29 |
#include <Foundation/NSData.h> |
#include <Foundation/NSData.h> |
30 |
#include <Foundation/NSURL.h> |
#include <Foundation/NSURL.h> |
31 |
#include <Foundation/NSHost.h> |
#include <Foundation/NSHost.h> |
32 |
|
#include <Foundation/NSProcessInfo.h> |
33 |
|
|
34 |
#include "Network/NetServer.h" |
#include "Network/NetServer.h" |
35 |
#include "Network/NetParty.h" |
#include "Network/NetParty.h" |
43 |
|
|
44 |
|
|
45 |
/* FIXE ME (enlever address dans la requete) */ |
/* FIXE ME (enlever address dans la requete) */ |
46 |
NSString * const _updateServerListURL = @"http://meta.hegemonie.org/proc_update_server?address=%@&game_name=%@&num_players=%hu&max_num_players=%hu&master=%@&map_name=%@"; |
NSString * const _updateServerListURL = @"http://meta.hegemonie.org/proc_update_server?address=%@&game_name=%@&num_players=%hu&max_num_players=%hu&&map_name=%@&master=%@&operating_system=%@"; |
47 |
|
|
48 |
|
|
49 |
/** |
/** |
95 |
/** |
/** |
96 |
* Update the meta server data with party's informations. |
* Update the meta server data with party's informations. |
97 |
*/ |
*/ |
98 |
+ (BOOL) updateServerListWithParty : (NetParty *)party |
- (BOOL) updateServerListWithParty: (NetParty *)party |
99 |
{ |
{ |
100 |
NSParameterAssert (party); |
NSParameterAssert (party); |
101 |
|
|
108 |
_convertForURL([party gameName]), |
_convertForURL([party gameName]), |
109 |
[party numPlayers], |
[party numPlayers], |
110 |
[party maxNumPlayers], |
[party maxNumPlayers], |
111 |
|
_convertForURL([party mapName]), |
112 |
_convertForURL([party master]), |
_convertForURL([party master]), |
113 |
_convertForURL([party mapName])]; |
[[NSProcessInfo processInfo] operatingSystemName]]; |
114 |
url = [NSURL URLWithString: addressRequest]; |
url = [NSURL URLWithString: addressRequest]; |
115 |
data = [NSData dataWithContentsOfURL: url]; |
data = [NSData dataWithContentsOfURL: url]; |
116 |
|
|
117 |
puts ([addressRequest cString]); |
// puts ([addressRequest cString]); |
118 |
|
|
119 |
if ([data length] != 0) |
if ([data length] != 0) |
120 |
{ |
{ |
|
puts ((char *)[data bytes]); |
|
121 |
return YES; |
return YES; |
122 |
} |
} |
123 |
else |
else |
165 |
NetConnection *connexion; |
NetConnection *connexion; |
166 |
NSPort *port; |
NSPort *port; |
167 |
|
|
|
puts ("Entre dans addParty"); |
|
|
|
|
168 |
NSException *myException = [NSException |
NSException *myException = [NSException |
169 |
exceptionWithName:@"partyNameException" |
exceptionWithName:@"partyNameException" |
170 |
reason:@"partyName already exists" |
reason:@"partyName already exists" |
183 |
|
|
184 |
[connexion registerName: [party gameName]]; |
[connexion registerName: [party gameName]]; |
185 |
|
|
186 |
|
if ([self updateServerListWithParty: party] == YES) |
187 |
puts("Party enregistrée"); |
puts ("Meta server is updated"); |
|
|
|
|
|
|
|
if ([NetServer updateServerListWithParty: party] == YES) |
|
|
puts ("OK"); |
|
188 |
else |
else |
189 |
puts ("Pas Ok"); |
puts ("Error -> meta server is not updated"); |
190 |
} |
} |
191 |
|
|
192 |
|
|