void AuthSocket::ProcessData( const byte *buf,size_t len ) { ByteBuffer packetContents(buf,len); DEBUG_LOG(format("Auth Receieved |%1%|") % Bin2Hex(packetContents)); byte packetOpcode; packetContents >> packetOpcode; AuthOpcode opcode = AuthOpcode(packetOpcode); switch (opcode) { default: { break; } case AS_GetPublicKeyRequest: { HandleGetPublicKeyRequest(packetContents); break; } case AS_AuthRequest: { HandleAuthRequest(packetContents); break; } case AS_AuthChallengeResponse: { HandleAuthChallengeResponse(packetContents); break; } } }
void WSSocket::OnRead() { for(;;) { if(!_cmd) { if(readBuffer.GetSize() < 6) break; readBuffer.Read(&_cmd, 2); readBuffer.Read(&_remaining, 4); } if(_remaining && readBuffer.GetSize() < _remaining) break; if(_cmd == ICMSG_WOW_PACKET) { uint32 sid; uint16 op; uint32 sz; GetReadBuffer().Read(&sid, 4); GetReadBuffer().Read(&op, 2); GetReadBuffer().Read(&sz, 4); Session * session = sClientMgr.GetSession(sid); if(session != NULL && session->GetSocket() != NULL) { uint8* buf = new uint8[sz]; GetReadBuffer().Read(buf, sz); session->GetSocket()->OutPacket(op, sz, buf); delete [] buf; } else GetReadBuffer().Remove(sz); _cmd = 0; continue; } WorldPacket * pck = new WorldPacket(_cmd, _remaining); _cmd = 0; pck->resize(_remaining); readBuffer.Read((uint8*)pck->contents(), _remaining); if(_authenticated) { // push to queue if(!_ws) { if(pck->GetOpcode() == ICMSG_REGISTER_WORKER) { // handle register worker HandleRegisterWorker(*pck); } /* I deliberately don't delete pck here for a reason :P */ } else { _ws->QueuePacket(pck); } } else { if(pck->GetOpcode() != ICMSG_AUTH_REPLY) Disconnect(); else HandleAuthRequest(*pck); delete pck; } } }