Ok, recently i came up with a new networking concept, but i’m experiencing a bug.
Instead of having a single predefined network object, you have 3 components.
Firstly, a terminal component which sends and receives data that it is fed over the network. It essentially acts as a bridge between the client and the server.
The second component is called a “plugin_sender”.
These plugins can be multiple (more than one per object, more than one per scene), and each perform a specific, non-conflicting task.
The last component is the “plugin_receiver”. The plugin receiver simply interprets the data relating to that plugin type and utilises it.
I will give you an example. You have the terminal running, and the server.
The “position_plugin” sends the location of it’s owner to the terminal. The other client receives this data, and it is interpreted by the position_plugin receiver. This works fine with two clients, but with any more, the game objects ‘flash’.
Why this occurs?
I beleive that this occurs because of the condition which means that a plugin receiver ignores data sent by its own terminal (it doesn’t need to set its own objects!).
So, when there are two clients, although there are two sets of data, only one is iterated through, because it is the other clients data. However when there aer more than two clients sending data, when it is received as a list from the server it is iterated through more than once, as it is data from other clients. I beleive that because in my code (as you will see) the first iterator is “each set of data in the received list”, and as the process further down in the nested chain is slowish (a few ms?) it delays the time for each client object iteration.
When a client connects, each plugin receiver looks for data sent from a sender of its own type.
If it receives data from a sender that has not been recorded as an existing sender, it adds an object, and tags it for updating. There is more to it, but it is not relevant, its just to do with senders per object.
can anyone help? This code is in the format of Moguri’s component system, and the only noticeable difference is the start function, which is run once on init, and the update which is run every frame. There are self variables which act as object variables.
I’ll post the terminal code (which works fine!) and the plugins code.
terminal.py
plugins.py
If you are unsure how to set it up, read below:
download the patched blender (for windows) here.
Copy the two files into this folder: “PATCHEDBLENDER/2.57/scripts/bge_components/”
open four instances of the patched blender.
in one instance, on the default cube in the logic panel there is a “components panel”.
type “terminal.server”, click Add Component and start the game
in the other three instances, do the following:
move the default cube to layer 2
on layer one make 3 objects.
on one type “terminal.client”, click Add Component
on the next type “plugins.position_encode”, click Add Component
on the next type “plugins.position_decode”, click Add Component
save this, and open it in the other two instances of blender.
now start those three instances.
watch :@