Changeset 4674
- Timestamp:
- 02/20/07 16:58:53 (2 years ago)
- Files:
-
- wire/branches/p7/wire/client.c (modified) (8 diffs)
- wire/branches/p7/wire/client.h (modified) (1 diff)
- wire/branches/p7/wire/main.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
wire/branches/p7/wire/client.c
r4625 r4674 144 144 145 145 wi_socket_t *wr_socket; 146 wi_p7_socket_t *wr_p7_socket; 146 147 wi_address_t *wr_address; 147 148 … … 178 179 wr_icon = wi_string_init_with_cstring(wi_string_alloc(), wr_default_icon); 179 180 180 wr_p7_spec = wi_p7_spec_init_with_file(wi_p7_spec_alloc(), WI_STR(" protocol.xml"));181 wr_p7_spec = wi_p7_spec_init_with_file(wi_p7_spec_alloc(), WI_STR("wired.xml")); 181 182 182 183 if(!wr_p7_spec) … … 194 195 wi_socket_t *socket; 195 196 wi_p7_socket_t *p7_socket; 197 wi_cipher_t *cipher; 196 198 wi_string_t *ip; 197 199 … … 213 215 } 214 216 215 // enumerator = wi_array_data_enumerator(addresses); 216 217 // while((address = wi_enumerator_next_data(enumerator))) { 218 address = wi_array_first_data(addresses); 217 enumerator = wi_array_data_enumerator(addresses); 218 219 while((address = wi_enumerator_next_data(enumerator))) { 219 220 ip = wi_address_string(address); 220 221 … … 223 224 wi_address_set_port(address, port); 224 225 225 socket = wi_ socket_init_with_address(wi_socket_alloc(), address, WI_SOCKET_TCP);226 socket = wi_autorelease(wi_socket_init_with_address(wi_socket_alloc(), address, WI_SOCKET_TCP)); 226 227 wi_socket_set_interactive(socket, true); 227 228 … … 229 230 wr_printf_prefix(WI_STR("Could not connect to %@: %m"), ip); 230 231 231 goto next; 232 } 233 234 p7_socket = wi_p7_socket_init_with_socket(wi_p7_socket_alloc(), socket, wr_p7_spec); 235 236 if(!wi_p7_socket_connect(p7_socket, 10.0, WI_P7_COMPRESSION_DEFLATE | WI_P7_ENCRYPTION_RSA_AES_256, WI_P7_BINARY, login, password)) { 232 continue; 233 } 234 235 p7_socket = wi_autorelease(wi_p7_socket_init_with_socket(wi_p7_socket_alloc(), socket, wr_p7_spec)); 236 237 // if(!wi_p7_socket_connect(p7_socket, 10.0, WI_P7_ENCRYPTION_RSA_AES_256 | WI_P7_COMPRESSION_DEFLATE, WI_P7_XML, login, password)) { 238 if(!wi_p7_socket_connect(p7_socket, 10.0, WI_P7_ENCRYPTION_RSA_AES_256 | WI_P7_COMPRESSION_DEFLATE, WI_P7_BINARY, login, password)) { 237 239 wr_printf_prefix(WI_STR("Could not connect to %@: %m"), ip); 238 240 239 goto next; 240 } 241 242 /* wr_printf_prefix(WI_STR("Connected using %@/%@/%u bits, logging in..."), 243 wi_socket_cipher_version(socket), 244 wi_socket_cipher_name(socket), 245 wi_socket_cipher_bits(socket));*/ 246 wr_printf_prefix(WI_STR("Connected, logging in...")); 241 continue; 242 } 243 244 cipher = wi_p7_socket_cipher(p7_socket); 245 246 if(cipher) { 247 wr_printf_prefix(WI_STR("Connected using %@/%u bits, logging in..."), 248 wi_cipher_name(cipher), 249 wi_cipher_bits(cipher)); 250 } else { 251 wr_printf_prefix(WI_STR("Connected, logging in...")); 252 } 247 253 248 254 wr_connected = true; … … 252 258 wr_password = wi_retain(password); 253 259 wr_socket = wi_retain(socket); 260 wr_p7_socket = wi_retain(p7_socket); 254 261 wr_address = wi_retain(address); 255 262 256 263 wr_runloop_add_socket(wr_socket, &wr_runloop_server_callback); 257 wr_send_command(WI_STR("HELLO")); 258 259 next: 260 wi_release(socket); 261 262 if(wr_connected) 263 ; 264 // } 264 265 { 266 wi_p7_message_t *message = wi_p7_message_with_name(WI_STR("wired.info"), wr_p7_socket); 267 wi_p7_message_set_string_for_name(message, WI_STR("wire"), WI_STR("wired.info.application.name")); 268 269 wi_p7_socket_write_message(wr_p7_socket, 0.0, message); 270 } 271 272 break; 273 } 265 274 266 275 if(wr_socket) … … 273 282 wr_runloop_remove_socket(wr_socket); 274 283 wi_release(wr_socket); 284 wi_release(wr_p7_socket); 275 285 276 286 if(wr_connected) { wire/branches/p7/wire/client.h
r4423 r4674 85 85 86 86 extern wi_socket_t *wr_socket; 87 extern wi_p7_socket_t *wr_p7_socket; 87 88 extern wi_address_t *wr_address; 88 89 wire/branches/p7/wire/main.c
r4569 r4674 342 342 343 343 if(interval - ping_interval > 60.0) { 344 wr_send_command(WI_STR("PING")); 344 wi_p7_message_t *message; 345 346 message = wi_p7_message_with_name(WI_STR("wired.ping"), wr_p7_socket); 347 348 if(!wi_p7_socket_write_message(wr_p7_socket, 10.0, message)) 349 wr_printf_prefix(WI_STR("write: %m")); 345 350 346 351 ping_interval = interval;
