Game Development Community

Can i send packet specific group user ?

by HoSung,Kim · in Torque Game Engine · 08/10/2006 (8:18 pm) · 7 replies

I have a another question.

example.

If four user connect the server.

A user,
B user,
C user,
D user,


I want send packet for A,C user only.

How can I do it ?


please... help me.

#1
08/11/2006 (10:21 am)
I'm just learning myself, but I think it goes like this.
I'm going to offer my fullest explanation of TNL concepts, especially those I found non-obvious

NetInterface is a socket. Both Client and Server must have at least one. The NetInterface does only UDP traffic, but the NetConnections that use it support a "connection" which stays active provided traffic continues to flow.

NetConnections (and EventConnections and GhostConnections) connect through a NetInterface, and for any given connection, there will be one on the client and one (of the same class!) on the server.

The NetInterface on the server, when more than a single client is connected, has MORE than one NetConnection using it. They are maintained in a list on the server's NetInterface object.

If a server wants to send something to more than a single client, it does so by iterating through the list of NetConnections on its NetInterface and sending it down the chosen connections.

To sum up:

-- a server is created by creating a NetInterface with the proper constructor (see example code).
-- a client creates not only a NetInterface, but a NetConnection of some kind. It then asks the NetConnection to connect "through" the NetInterface by specifying "IP:hostIPAddress:portNumber". When this works, the server AUTOMATICALLY has a NetConnection instantiated and placed onto the list of NetConnections on its NetInterface. This represents the server's connection to the client.
-- if the server wants to send an event to some (but not all) of the clients, it iterates through the NetConnections on the NetInterface and chooses which to send it to.

Lastly, it bears mention that the NetObject ghosting mechanism has many of these behaviors built in through the concept of a "scoping object". You might read that documentation closely.

Let me know if this is not clear, or if you need more detail.


tone
#2
08/11/2006 (11:17 am)
Also, depending on how you are setting up your users, there are different ways to pick a certain one. resolveGhost/resolveGhostParent will be useful if you're using the ghosting method (NetObjects) for users. If you're just using a custom solution (as I am) and just communicating user positions through NetEvents, you can store a unique ID in each user's NetInterface. For my application, I use the user's IP as the unique ID.
#3
08/13/2006 (6:00 pm)
Ok, It's a nice explain.
Thank you very much

with Anthony Lovell's note.

my understanding step.

on server :
create NetInterface
on NetConnection::receivedPacket()
NetConnection::readPacket()

process.

To select User, get each NetConnection, use getConnectionList()
sendPacket()


on client :
create NetInterface
create NetConnection
use NetConnection::connect()
on NetConnection::receivedPacket()
NetConnection::readPacket()

process.

sendPacket()


Here is another question.

NetConnection always Reliable or how do i add reliable function ?

How do i use NetEvent with NetConnection and NetInterface ?

Thank you again.
#4
08/13/2006 (7:38 pm)
I checked Document.

Reliable transmission, may use EventConnection.

now, I have more information about EventConnection and NetEvent relationship.

If I use EventConnection, How retrive EventConnection From NetInterface ?
#5
08/13/2006 (9:03 pm)
The eventconnection is a subclass of the netconnection. Just do a dynamic_cast - that's why we have the classes on each end match (sort of).

You may find TNL difficult to use if you're not familiar with C++.
#6
08/13/2006 (10:00 pm)
I have enough knowledge of C++. ;)

I wonder how can I link my NetConnection subclass with NetInterface on server side.
I can't understand.
#7
08/13/2006 (10:36 pm)
OK, found the clue.
It may be IMPLEMENT_NET_CONNECT() macro.
I'll try

if I fail I'll be back.

Thank you very much.