-
Notifications
You must be signed in to change notification settings - Fork 5
Getting Started
#Importing the library
To avoid namespace clutter, most modules in the library must be imported directly, rather than using from network import *. It is recommended to import specific objects, rather than all members from a namespace, to avoid confusion later on.
First of all, you'll need to establish a client or server:
from network.enums import Netmodes
from network.world_info import WorldInfo
# Setup server
WorldInfo.netmode = Netmodes.server
# Or, setup client
WorldInfo.netmode = Netmodes.client#Use with game_system
If you want to make use of a XXX_game_system library, why not import a blocking game loop?
from panda_game_system.game_loop import Client, Server
if WorldInfo.netmode == Netmodes.server:
loop = Server()
else:
loop = Client()
# Blocking gameloop
loop.delegate()This will setup a number of systems required to run the game. It will also take care of the Panda ShowBase system, if using Panda3D.
#Connection to a Server
Connecting to a remote server (for a client) can be done in a number of ways, all ultimately calling the classmethod Connection.create_connection, which returns a Connection instance:
- The
Networkclass instance (provided by default in the game loop instance inGameLoop.network_system) has aconnect_tomethod, which accepts the ip address and port of the remote peer. - The
Clientgame loop instance provides a methodnew_connectionwhich also accepts the ip address and port of the remote peer. - The
SignalinstanceConnectToSignal, defined ingame_system.signals, can be invoked for a client, which ultimately callsClient.new_connection.
#Network
##Replication Overview
##Serialisation Data handlers
##Communication Messaging
#Game Framework ##Bindings Creating bindings