void RceQueryPvE::MergeFrom(const RceQueryPvE& from) { GOOGLE_CHECK_NE(&from, this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from._has_bit(0)) { set_type(from.type()); } if (from._has_bit(1)) { set_pass(from.pass()); } } mutable_unknown_fields()->MergeFrom(from.unknown_fields()); }
void RceLogin::MergeFrom(const RceLogin& from) { GOOGLE_CHECK_NE(&from, this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from._has_bit(0)) { set_pass(from.pass()); } if (from._has_bit(1)) { set_nick(from.nick()); } } mutable_unknown_fields()->MergeFrom(from.unknown_fields()); }
void RseAuthState::MergeFrom(const RseAuthState& from) { GOOGLE_CHECK_NE(&from, this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from._has_bit(0)) { set_pass(from.pass()); } if (from._has_bit(1)) { set_type(from.type()); } if (from._has_bit(2)) { set_leftmin(from.leftmin()); } } mutable_unknown_fields()->MergeFrom(from.unknown_fields()); }
/* *Main thread for each client. Receives all messages *and passes the data off to the correct function. Receives *a pointer to the file descriptor for the socket the thread *should listen on */ void *client_receive(void *ptr) { int client = *(int *) ptr; int received; int logged_in = 0; packet in_pkt, *client_message_ptr = &in_pkt; while (1) { received = recv(client, &in_pkt, sizeof(packet), 0); if (received) { debugPacket(client_message_ptr); // Responses to not logged in clients if (!logged_in) { if(in_pkt.options == REGISTER) { logged_in = register_user(&in_pkt, client); } else if(in_pkt.options == LOGIN) { logged_in = login(&in_pkt, client); } else if(in_pkt.options == EXIT) { close(client); return NULL; } else { sendError("Not logged in.", client); } } // Responses to logged in clients else if (logged_in) { // Handle option messages for logged in client if (in_pkt.options < 1000) { if(in_pkt.options == REGISTER) { sendError("You may not register while logged in.", client); } else if(in_pkt.options == SETPASS) { set_pass(&in_pkt, client); } else if(in_pkt.options == SETNAME) { set_name(&in_pkt, client); } else if(in_pkt.options == LOGIN) { sendError("Already logged in.", client); } else if(in_pkt.options == EXIT) { exit_client(&in_pkt, client); return NULL; } else if(in_pkt.options == INVITE) { invite(&in_pkt, client); } else if(in_pkt.options == JOIN) { join(&in_pkt, client); } else if(in_pkt.options == LEAVE) { leave(&in_pkt, client); } else if(in_pkt.options == GETALLUSERS) { get_active_users(client); } else if(in_pkt.options == GETUSERS) { get_room_users(&in_pkt, client); } else if(in_pkt.options == GETUSER) { user_lookup(&in_pkt, client); } else if(in_pkt.options == GETROOMS) { get_room_list(client); } else if(in_pkt.options == GETMOTD) { sendMOTD(client); } else if(in_pkt.options == 0) { printf("%s --- Error:%s Abrupt disconnect on logged in client.\n", RED, NORMAL); exit_client(&in_pkt, client); return NULL; } else { printf("%s --- Error:%s Unknown message received from client.\n", RED, NORMAL); } } // Handle conversation message for logged in client else { // Will be treated as a message packet, safe to santize entire buffer sanitizeInput((void *)&in_pkt.buf, 0); send_message(&in_pkt, client); } } memset(&in_pkt, 0, sizeof(packet)); } } return NULL; }