… | |
… | |
351 | } |
351 | } |
352 | else |
352 | else |
353 | { |
353 | { |
354 | inbuf_len += amount; |
354 | inbuf_len += amount; |
355 | |
355 | |
356 | cmd_ev.start (); |
|
|
357 | } |
|
|
358 | } |
|
|
359 | } |
|
|
360 | |
|
|
361 | // called whenever we have additional commands to process |
|
|
362 | void |
|
|
363 | client::cmd_cb (iw &w) |
|
|
364 | { |
|
|
365 | if (handle_packet ()) |
356 | if (handle_packet ()) |
366 | w.start (); |
357 | { |
367 | else |
358 | while (handle_packet ()) |
368 | flush (); |
359 | ; |
|
|
360 | |
|
|
361 | flush (); |
|
|
362 | } |
|
|
363 | } |
|
|
364 | } |
369 | } |
365 | } |
370 | |
366 | |
371 | /******************************************************************************* |
367 | /******************************************************************************* |
372 | * |
368 | * |
373 | * Start of write related routines. |
369 | * Start of write related routines. |
… | |
… | |
487 | } |
483 | } |
488 | |
484 | |
489 | void |
485 | void |
490 | client::send_msg (int color, const char *type, const char *msg) |
486 | client::send_msg (int color, const char *type, const char *msg) |
491 | { |
487 | { |
492 | if (msg_is_special (msg)) |
488 | if (!msg || !type) // it can happen (for example, missing attack messages cause this) |
|
|
489 | { |
|
|
490 | LOG (logBacktrace | llevError, "send_msg(%d,%p,%p) called with NULL msg or type.\n", color, type, msg); |
|
|
491 | return; |
|
|
492 | } |
|
|
493 | |
|
|
494 | int len = strlen (msg); |
|
|
495 | |
|
|
496 | if (msg_is_special (msg) || (type [0] == 'c' && type [1] == '/') || len > (MAXSOCKBUF - 128)) |
493 | cfperl_send_msg (this, color, type, msg); |
497 | cfperl_send_msg (this, color, type, msg); |
494 | else if (can_msg) |
498 | else if (can_msg) |
495 | send_packet_printf ("msg %d %s %s", color & NDI_CLIENT_MASK, type, msg); |
499 | send_packet_printf ("msg %d %s %s", color & NDI_CLIENT_MASK, type, msg); |
496 | else if (color < 0) |
500 | else if (color < 0) |
497 | return; // client cannot handle this |
501 | return; // client cannot handle this |