mirror of
https://github.com/panda3d/panda3d.git
synced 2026-01-24 00:13:49 -06:00
1: Simple client-server connection 2: Client-server connection with timeManager 3: Create distributed objects, sending and receiving messages 4: Distributed model file 5: Simple text chat 6: Simple smooth moving actor
26 lines
1.0 KiB
Python
26 lines
1.0 KiB
Python
from direct.distributed.DistributedObjectAI import DistributedObjectAI
|
|
|
|
class AIDGameObjectAI(DistributedObjectAI):
|
|
def __init__(self, aiRepository):
|
|
DistributedObjectAI.__init__(self, aiRepository)
|
|
|
|
def messageRoundtripToAI(self, data):
|
|
""" The client sent us some data to process. So work with it and send
|
|
changed data back to the requesting client """
|
|
requesterId = self.air.getAvatarIdFromSender()
|
|
print("Got client data:", data, "from client with ID", requesterId)
|
|
|
|
# do something with the data
|
|
aiChangedData = (
|
|
data[0] + " from the AI",
|
|
data[1] + 1,
|
|
data[2])
|
|
|
|
print("Sending modified game data back:", aiChangedData)
|
|
self.d_messageRoundtripToClient(aiChangedData, requesterId)
|
|
|
|
def d_messageRoundtripToClient(self, data, requesterId):
|
|
""" Send the given data to the requesting client """
|
|
print("Send message to back to:", requesterId)
|
|
self.sendUpdateToAvatarId(requesterId, 'messageRoundtripToClient', [data])
|