Archived

This topic is now archived and is closed to further replies.

Shannon Barber

DP8 Client/Server

Recommended Posts

Hi,

I''m using VB and DirectPlay. But I''ve checked the C++ DirectX8 docs. I do not know much about C++, but I guess your server uses a callback to receive all the DirectPlay events. Now, when a "DPN_MSGID_RECEIVE" message arrives, it contains a structure/type named "DPNMSG_RECEIVE".

Which looks like

typedef struct {
DWORD dwSize;
DPNID dpnidSender;
PVOID pvPlayerContext;
PBYTE pReceiveData;
DWORD dwReceiveDataSize;
DPNHANDLE hBufferHandle;
} DPNMSG_RECEIVE, *PDPNMSG_RECEIVE;


The second item in this ''structure'' Is the PlayerID of the sender (client). The PlayerId is *always* sent. If you want to give the client the playerid, there is no way to get it, the only method is by sending it with a packet to the server (Atleast in VB)

Hope this helps,
Almar

Share this post


Link to post
Share on other sites
Thanks, I thought it was something simple I was overlooking.

Now, the primary thing my server does is relay packets from one client to all the others. Do I need to embeddeed the orginal DPNID in my packets, or is there a way to make the server send a packet with a DPNID other than 0?

Share this post


Link to post
Share on other sites
I'm using DX7 [edit](DirectPlay4) [/edit], and it is possible to cut the id from the messages by setting the DPSESSION_NOMESSAGEID flag in the DPSESSIONDESC2 structure you use to join a session. I don't know how is DPlay handling sending player IDs (anyone ?), but if it sends them as ints, you could save 3 bytes / ID by disabling DPlay IDs and using custom byte size IDs. Also, in a client server setup, the destination ID is pretty much useless for the server machine (all incoming messages go to the server). Anyway, here's the quote from the DX SDK 7.0 doc.

quote:

DPSESSION_NOMESSAGEID
Specifies that the session does not attach data to messages that indicate which player the message is from and to whom it is sent. Setting this flag saves message overhead if this information is not relevant. (For more information, see the IDirectPlay4::Receive method.) If this flag is not specified, the message ID will be added. This flag must be specified at the time the session is created



Edited by - Diodor on July 29, 2001 3:07:40 PM

Share this post


Link to post
Share on other sites
quote:

Now, the primary thing my server does is relay packets from one client to all the others. Do I need to embeddeed the orginal DPNID in my packets, or is there a way to make the server send a packet with a DPNID other than 0?



Well, in my game I also mainly forward the packets that arrive at the server (except for some special events) I just add the playerID of the player that sent the original packet to the packet. With this method I can easily identify which player sent the message.

For example, if someone dies I could let the server sent a message like: "Player1 was killed by longplayername". Takes a relative huge amount of bytes. When someone dies I jsut sent a packet header (1 byte) and two playerid''s (2x long(/dword?) = 4 bytes). The client side will check which playername belongs to what playerid. Saving bandwidth!


To Diodor: With DirectPlay8 and VB the PlayerID''s are 4 bytes. It''s possible to make your own system with structs and whatever C++ I don''t know, Linked lists, etc, but if something does go wrong somewhere, you''re in deep trouble =-) For example my movement packets could arrive at some other player. Currently my packets are 25bytes, I could cut off 3 bytes.. making it 22. Not sure if it''s worth it. I do have to add 5 bytes though I guess. 1 byte ID, and 4 for the cheat protection...

also, in DirectPlay8 You do not have the ability anymore to specify a destination. client and Server are two separate objects. Only the Server Object has a "SendTo" capability

btw, I was wondering. When using a byte the maximum would be 255 players (specifying 0 would go to all, that''s why 255 instead of 256) so an integer (Vb) would go next.. 2 bytes, so you''ll only remove two bytes.

And just one small thing... That quote is for DirectPlay4, not sure if it''s still in DX8 (or 7)

Hope this helps,
Almar

Share this post


Link to post
Share on other sites
I was hoping the DP server would have a mechanism built-in to identify the orginator of the packet, since you''re almost always going to need that.

I can use both suggestions, if DP doesn''t add the DPNID for you, then you gotta put it in the packet yourself. And there''s no sense in having the server send it''s DPNID to the client... it;d be nice if I could replace it with the orginal client DPNID.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:

I can use both suggestions, if DP doesn''t add the DPNID for you, then you gotta put it in the packet yourself. And there''s no sense in having the server send it''s DPNID to the client... it;d be nice if I could replace it with the orginal client DPNID.



Yeah, I agree with that. I''ve just checked The (VB) SDK docs for it... And made a few changes in my Masterserver(server) and dedicated server(client). The playerid that the dedicated server gets from a packet, sent by the masterserver is: 0!

And the Masterserver''s PlayerID isn''t 0, so I suppose it just isn''t sent, or just as one byte.

Hope this helps,
Almar

Share this post


Link to post
Share on other sites