DirectPlay - how to get the local DPNID ???
hi,
i have problem with DirectPlay (Peer2Peer):
for some tasks i need to get my local DPNID. but the sdk dosn''t provide any function for this.
this is why i do this:
- first i call ::EnumPlayersAndGroups(..,..,DPNENUM_PLAYERS) to get a list with all player DPNID''s
- after this i call ::GetPeerAddress() with each DPNID from the list
- the documentation says: "If the player calls this method on his or her own ID, it returns a DPNERR_INVALIDPLAYER"
- so my local DPNID should be the one, if ::GetPeerAddress() returns DPNERR_INVALIDPLAYER
BUT: if my app is a peer (not the p2p host) ::GetPeerAddress() does never return DPNERR_INVALIDPLAYER !!! (if my app is the host everything works fine...)
rené
I have this same problem, so I''m using this as a bump.
Alexander
Alexander
Alexander "DmGoober" Jhinalexjh@online.microsoft.com[Warning! This email account is not attended. All comments are the opinions of an individual employee and are not representative of Microsoft Corporation.]
Ok, so here''s the solution from my friend who works on DPLAY. Excuse the formatting, it''s copied directly from email:
-------------------------------------------------------------
In your message handler for DPNMSG_CREATE_PLAYER, you can catch your local player’s DPNID.
In your call to Connect() make sure to specify a unique player context. When you are handling your DPNMSG_CREATE_PLAYER, check each context value that comes in against your known local player context. If they match, then you can pull the local player’s DPNID from that message.
//connect and specify a unique context value
void CPlayer::Connect()
{
m_pPlayer->Connect(…,…,…,…,…,…,…, this, …, …, ….);
}
//handle the CreatePlayer msg
void CPlayer::HandleCreatePlayer(PVOID pMsg)
{
DPNMSG_CREATE_PLAYER * pCreatePlayer = (DPNMSG_CREATE_PLAYER *)pMsg;
If(pCreatePlayer->pvPlayerContext == this)
{
//found the local player
m_dpnId = pCreatePlayer->dpnidPlayer; //store the DPNID in a member variable
}
else
{
//not the local player, so do something else
}
}
Hope that helps. Alexander
-------------------------------------------------------------
In your message handler for DPNMSG_CREATE_PLAYER, you can catch your local player’s DPNID.
In your call to Connect() make sure to specify a unique player context. When you are handling your DPNMSG_CREATE_PLAYER, check each context value that comes in against your known local player context. If they match, then you can pull the local player’s DPNID from that message.
//connect and specify a unique context value
void CPlayer::Connect()
{
m_pPlayer->Connect(…,…,…,…,…,…,…, this, …, …, ….);
}
//handle the CreatePlayer msg
void CPlayer::HandleCreatePlayer(PVOID pMsg)
{
DPNMSG_CREATE_PLAYER * pCreatePlayer = (DPNMSG_CREATE_PLAYER *)pMsg;
If(pCreatePlayer->pvPlayerContext == this)
{
//found the local player
m_dpnId = pCreatePlayer->dpnidPlayer; //store the DPNID in a member variable
}
else
{
//not the local player, so do something else
}
}
Hope that helps. Alexander
Alexander "DmGoober" Jhinalexjh@online.microsoft.com[Warning! This email account is not attended. All comments are the opinions of an individual employee and are not representative of Microsoft Corporation.]
your solution seems to work, but there is also yet an other way to get the local DPNID.
i posted the same question yesterday on win32.programmer.directx.networking and there is a reply.
(see http://msdn.microsoft.com/newsgroups/default.asp?url=/newsgroups/loadframes.asp?icp=msdn&slcid=us&newsgroup=microsoft.public.win32.programmer.directx.networking for more details)
during the last hours i also found this new solution by myself and after this there came an OFFICIAL answer from microsoft (sometimes it is not good to torture my brain - however sometimes it is better to wait ...).
but now here the OFFICAL answer:
"Upon connecting to the session, your peer will receive
DPN_MSGID_CREATE_PLAYER messages for everyone in the session (include the
local peer). You can use the dpnidPlayer field from this message to call
GetPeerInfo(). If the dwPlayerFlags field of the returned structure contains
DPNPLAYER_LOCAL, you then know your local dpnid. Simply store your local
dpnid when you join the session and use the stored value throughout the
game. For example code, check the DirectX SDK samples (most of them perform
this check)."
hope this will also help !!!
rené (aka digital_drug)
i posted the same question yesterday on win32.programmer.directx.networking and there is a reply.
(see http://msdn.microsoft.com/newsgroups/default.asp?url=/newsgroups/loadframes.asp?icp=msdn&slcid=us&newsgroup=microsoft.public.win32.programmer.directx.networking for more details)
during the last hours i also found this new solution by myself and after this there came an OFFICIAL answer from microsoft (sometimes it is not good to torture my brain - however sometimes it is better to wait ...).
but now here the OFFICAL answer:
"Upon connecting to the session, your peer will receive
DPN_MSGID_CREATE_PLAYER messages for everyone in the session (include the
local peer). You can use the dpnidPlayer field from this message to call
GetPeerInfo(). If the dwPlayerFlags field of the returned structure contains
DPNPLAYER_LOCAL, you then know your local dpnid. Simply store your local
dpnid when you join the session and use the stored value throughout the
game. For example code, check the DirectX SDK samples (most of them perform
this check)."
hope this will also help !!!
rené (aka digital_drug)
Uh, the official Microsoft response is the same as what my friend suggested (my friend works at microsoft. ) Of course, the response you got was a little more clear than the response I got. . .
DmGoober
DmGoober
Alexander "DmGoober" Jhinalexjh@online.microsoft.com[Warning! This email account is not attended. All comments are the opinions of an individual employee and are not representative of Microsoft Corporation.]
but what about a client/server session (and you''re the server)?
The CREATE_PLAYER message just has a junk DPNID when you''re the host starting a new session (at least it does for me)..
??
The CREATE_PLAYER message just has a junk DPNID when you''re the host starting a new session (at least it does for me)..
??
Learn about game programming!Games Programming in C++: Start to Finish
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement