1

フォトンクラウドでHashtableを使用してデータを送信しようとしていますが、正しいeventCodeでデータを受信しますが、キーと値のペアがいくつかの乱数を返します。データ送信中の私のコードは次のようになります:-

void NetworkLogic::sendEvent(void)
{
    ExitGames::Common::Hashtable* table =new ExitGames::Common::Hashtable;
        table->put<int,int>(4,21);
        const ExitGames::Common::Hashtable temp = (const ExitGames::Common::Hashtable)*table;//= new ExitGames::Common::Hashtable;
        mLoadBalancingClient.opRaiseEvent(false, temp, 100);
}

データを受信して​​いる間、コードは次のようになります:-

void NetworkLogic::customEventAction(int playerNr, nByte eventCode, const ExitGames::Common::Hashtable& eventContent)
{
    // you do not receive your own events, unless you specify yourself as one of the receivers explicitly, so you must start 2 clients, to receive the events, which you have sent, as sendEvent() uses the default receivers of opRaiseEvent() (all players in same room like the sender, except the sender itself)
    PhotonPeer_sendDebugOutput(&mLoadBalancingClient, DEBUG_LEVEL_ALL, L"");
    cout<<((int)(eventContent.getValue(4)));
}

コンソールに出力されるのは、ランダムな値またはintですが、21である必要があります。ここで何が間違っているのでしょうか。

編集:
私が 次customEventAction()のステートメントを使用したとき:

cout<<eventContent.getValue(4)->getType()<<endl;
cout<<"Event code = "<<eventCode<<endl;

次の出力が得られました。

i
Event code = d

検索したところ、'i'その値は、EG_INTEGER送信している値が正しく受信されていることを意味します。に戻すことができませんでしたint。そして、なぜイベントコードが次のように来るの'd'ですか?

4

1 に答える 1

2
eventContent.getValue(4)

オブジェクトを返します。その Object を単純に int にキャストすることはできませんが、その中の int 値にアクセスする必要があります。

if(eventContent.getValue(4))
            myInt = ExitGames::Common::ValueObject<int>(eventContent.getValue(4)).getDataCopy();
cout << myInt;
于 2012-12-11T19:25:06.723 に答える