[ENet-discuss]pyenet: how to send data from server to client.

Ling Lo ling at slimy.com
Mon Jun 23 03:27:01 PDT 2003


enet-discuss-bounces at cubik.org wrote:
> Hello,
>
> I was wondering how to send data from the server to a specific client?
>
> I got broadcast from the server to the client working ok.  But later I
> want to be able to have multiple clients connect to the server and
> have the server send data to only specific clients.
>
> Also, I do a peer.send(0,"a message", 0) from the client, but the
> server doesn't seem to get the message.
>
> Thanks for any hints :)

Hiya,

It's worth setting the reliable flag:

peer.send(0, line, enet.FLAG_RELIABLE)

To get the peer object for the client, store the peer object when the client
connects, e.g.:

            # Handle networking
            result, event = self.host.service(ENetServerPeriod)
            if True == result:
                if enet.EVENT_CONNECT == event.type:
                    # Peer has connected
                    self.unnamedclientlist.append(event.peer)

Hope this helps
--
  |   Ling Lo
_O_O_



More information about the ENet-discuss mailing list