Shadowrun: Awakened 29 September 2011 - Build 871
Public Member Functions | Static Public Member Functions | Public Attributes
SraNetwork::SraPacket Class Reference

#include <SraPacket.h>

Inheritance diagram for SraNetwork::SraPacket:

List of all members.

Public Member Functions

virtual void Deserialize (RakNet::BitStream *source)
 De-serializes the package and reading the opcode. DO NOT call this from the derived classes.
virtual void Serialize (RakNet::BitStream *target)
 Serializes the package. BE SURE to call this from the derived classes.

Static Public Member Functions

static SraPacketGetPacketFromData (char *dataBuffer)

Public Attributes

unsigned char opCode

Detailed Description

Definition at line 30 of file SraPacket.h.


Member Function Documentation

void SraNetwork::SraPacket::Deserialize ( RakNet::BitStream source) [virtual]
SraPacket * SraNetwork::SraPacket::GetPacketFromData ( char *  dataBuffer) [static]

Definition at line 25 of file SraPacket.cpp.

References SraNetwork::ID_CHAT_CHANNEL_REGISTER, SraNetwork::ID_CHAT_CHANNEL_UNREGISTER, SraNetwork::ID_CHAT_MSG_REQUEST_PENDING, SraNetwork::ID_CONNECT_TO_SRV, SraNetwork::ID_CREATE_CHAR, SraNetwork::ID_CREATE_CHAR_REP, SraNetwork::ID_GET_CLIENT_CHARS, SraNetwork::ID_GET_SRVLIST, SraNetwork::ID_IAM_ALIVE, SraNetwork::ID_LOGIN_REP, SraNetwork::ID_LOGIN_REQ, SraNetwork::ID_QUIT, opCode, and packet.

    {
        // We only need to check for the first element here
        // all the other checks will be made by the corresponding
        // derived class.       
        if ( dataBuffer == 0 )
        {
            return 0;
        }

        // First, read the opcode:
        int opCode = dataBuffer[0];

        // Just to be sure we don't forget to remove the opcode ;)
        char* truncBuffer = dataBuffer + 1;

        // Now find the correct class for this code:
        // TODO: Create a more elegant solution with a ptr list 
        SraPacket* packet = 0;
        switch (opCode)
        {
            case ID_LOGIN_REQ :
                packet = new LoginPacket(); 
                //packet->Deserialize(truncBuffer);
                break;
            case ID_LOGIN_REP :
                break;
            case ID_QUIT :
                break;
            case ID_GET_SRVLIST :
                break;
            case ID_CONNECT_TO_SRV :
                break;
            case ID_GET_CLIENT_CHARS :
                break;
            case ID_CREATE_CHAR :
                break;
            case ID_CREATE_CHAR_REP :
                break;
            case ID_CHAT_MSG_REQUEST_PENDING :
                break;
            case ID_CHAT_CHANNEL_REGISTER :
                break;
            case ID_CHAT_CHANNEL_UNREGISTER :
                break;
            case ID_IAM_ALIVE :
                break;
        }
        
        return packet;
    }
void SraNetwork::SraPacket::Serialize ( RakNet::BitStream target) [virtual]

Member Data Documentation


The documentation for this class was generated from the following files:

Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.

GNU Lesser General Public License 3 Sourceforge.net