| 771 | |
| 772 | |
| 773 | bool ServerLink::readEnter(std::string& reason, |
| 774 | uint16_t& code, uint16_t& rejcode) { |
| 775 | // wait for response |
| 776 | uint16_t len; |
| 777 | char msg[MaxPacketLen]; |
| 778 | |
| 779 | while (true) { |
| 780 | if (this->read(code, len, msg, -1) < 0) { |
| 781 | reason = "Communication error joining game [No immediate response]."; |
| 782 | return false; |
| 783 | } |
| 784 | |
| 785 | if (code == MsgAccept) { |
| 786 | return true; |
| 787 | } |
| 788 | else if (code == MsgSuperKill) { |
| 789 | reason = "Server forced disconnection."; |
| 790 | return false; |
| 791 | } |
| 792 | else if (code == MsgReject) { |
| 793 | void* buf; |
| 794 | char buffer[MessageLen]; |
| 795 | buf = nboUnpackUInt16(msg, rejcode); // filler for now |
| 796 | buf = nboUnpackString(buf, buffer, MessageLen); |
| 797 | buffer[MessageLen - 1] = '\0'; |
| 798 | reason = buffer; |
| 799 | return false; |
| 800 | } |
| 801 | // ignore other codes so that bzadmin doesn't choke |
| 802 | // on the MsgMessage's that the server can send before |
| 803 | // the MsgAccept (authorization holdoff, etc...) |
| 804 | } |
| 805 | |
| 806 | return true; |
| 807 | } |
| 808 | |
| 809 | |
| 810 | #ifndef BUILDING_BZADMIN |
no test coverage detected