<?php

/**
 * lmf 测试网络消息
 */

namespace Test;

require_once __DIR__ . '/../Library/AutoLoad.php';

use Framework\Protobuf\WebRequestMessage;
use Framework\Protobuf\SinglePacket;
use Game\Protobuf\CGGetFestivalRewardInfo;
use Game\Protobuf\CGRefitItemBindCar;
use Game\Protobuf\CGRewardFestival;
use Game\Protobuf\CGRewardWeekLogin;
use Game\Protobuf\CGUpGradeCarSend;


const URL = "http://zone2.ng.com/GameIndex.php?zone=Zone_3";
const PLAYER_ID = 288783685596400017;
$message = new WebRequestMessage();
$message->setIndex(1);
$message->setServerId(3);
$message->setSession('12s123sdf');
$message->setPlayerId(PLAYER_ID);

$packet = new CGRefitItemBindCar();
$packet->setCarTplID(1006);
$packet->setRefitID(60001);
$packet->setRefitItemID(20000001);

$packetStr = base64_encode($packet->serializeToString());

$single_packet = new SinglePacket();
$single_packet->setId(460);
$single_packet->setData($packetStr);

$message->setPacketList([$single_packet]);
$packet_str = $message->serializeToString();

print_r($packet_str);
$curl = curl_init(URL);
$options = array(
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => $packet_str,
    CURLOPT_HEADER => false,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 10
);
curl_setopt_array($curl, $options);
curl_exec($curl);
curl_close($curl);

