- private function rawPacketRead($p_sResponse) {
- $iTotalSizeRead = 0;
- if (isset($this->m_aResponseBuff['packet'])) {
- $iPacketSizeRead = strlen($this->m_aResponseBuff['packet']);
- } else {
- $iPacketSizeRead = 0;
- }
- while ($iTotalSizeRead < strlen($p_sResponse)) {
- // New packet
- if (!isset($this->m_aResponseBuff['length'])) {
- $aLength = unpack('V1PacketLength', substr($p_sResponse, $iTotalSizeRead, 4));
- $this->m_aResponseBuff['length'] = $aLength['PacketLength'];
- $this->m_aResponseBuff['packet'] = null;
- $iTotalSizeRead += 4;
- $iPacketSizeRead = 0;
- }
- $this->m_aResponseBuff['packet'] .= substr($p_sResponse, $iTotalSizeRead, ( $this->m_aResponseBuff['length'] - $iPacketSizeRead ) );
- $iTotalSizeRead += ( $this->m_aResponseBuff['length'] - $iPacketSizeRead );
- if (strlen($this->m_aResponseBuff['packet']) == $this->m_aResponseBuff['length']) {
- $aResponse = unpack('V1RequestID/V1CommandResponse/a*String1/a*String2', $this->m_aResponseBuff['packet']);
- $this->m_aResponseBuff = array();
- if ($this->m_bAuthenticated === false && $aResponse['RequestID'] == 1 && $aResponse['CommandResponse'] == SERVERDATA_AUTH_RESPONSE) {
- // authenticated succesfully
- $this->m_bAuthenticated = true;
- } else if (array_key_exists($aResponse['RequestID'], $this->m_aResponses)) {
- // add to command response
- $this->m_aResponses[$aResponse['RequestID']]['String1'] .= $aResponse['String1'];
- $this->m_aResponses[$aResponse['RequestID']]['String2'] .= $aResponse['String2'];
- } else {
- // build new command response
- $this->m_aResponses[$aResponse['RequestID']] = array();
- $this->m_aResponses[$aResponse['RequestID']]['CommandResponse'] = $aResponse['CommandResponse'];
- $this->m_aResponses[$aResponse['RequestID']]['String1'] = $aResponse['String1'];
- $this->m_aResponses[$aResponse['RequestID']]['String2'] = $aResponse['String2'];
- }
- }
- }
- }
aap
By: Ik | Date: Sep 29 2008 20:21 | Format: None | Expires: never | Size: 1.94 KB | Hits: 1333
Latest pastes
1 hours ago
11 hours ago
1 days ago
2 days ago
2 days ago