Exemple #1
0
void NetClient::SendReadyToStartPacket()
{

    std::string strDName = GetDriverName();
    GfLogTrace("Sending ready to start packet\n");

    PackedBuffer msg;

    try
    {
        msg.pack_ubyte(CLIENTREADYTOSTART_PACKET);
        msg.pack_stdstring(strDName);
    }
//    catch (PackedBufferException &e)
    catch (PackedBufferException)
    {
        GfLogFatal("SendReadyToStartPacket: packed buffer error\n");
    }
    GfLogTrace("SendReadyToStartPacket: packed data length=%d\n",
            msg.length());

    ENetPacket *pPacket = enet_packet_create (msg.buffer(), 
            msg.length(), 
            ENET_PACKET_FLAG_RELIABLE);

    if (enet_peer_send (m_pServer, RELIABLECHANNEL, pPacket))
        GfLogError("SendReadyToStartPacket : enet_peer_send failed\n");
}
Exemple #2
0
bool NetServer::SendPlayerRejectedPacket(ENetPeer * pPeer,std::string strReason)
{
	//Send to client requesting connection

        PackedBuffer msg;

        try
        {
                msg.pack_ubyte(PLAYERREJECTED_PACKET);	
                msg.pack_stdstring(strReason);
        }
        catch (PackedBufferException &e)
        {
                GfLogFatal("SendPlayerRejectedPacket: packed buffer error\n");
        }
        GfLogTrace("SendPlayerRejectedPacket: packed data length=%d\n",
                msg.length());

	ENetPacket * pPacket = enet_packet_create (msg.buffer(), 
                                              msg.length(), 
                                              ENET_PACKET_FLAG_RELIABLE);

	if (enet_peer_send (pPeer, RELIABLECHANNEL, pPacket)==0)
		return true;

	return false;
}