RoRnet 2.3
From Rigs of Rods Wiki
Contents |
overview
the 2.3 protocol takes a new step in the evolution of the RoR MP protocol. It is more advanced than any of its predecessor:
- adds stream concept
- stripping of unneeded 2.2 functions
- ability to join without a vehicle
stream concept
a stream is a concept of a data flow that we use in this protocol design. Streams can be started, stopped, paused, unpaused and transferred (to another user). 2.3 might only implement some basic stream functions like start and stop.
a stream has the following properties:
- a unique ID for that player
- a type, currently:
- 0=vehicle
- 1=character
- 2=ai traffic
- 3=chat
- a state, 1=active (currently not in use)
unique identification throughout the server
The server will count the users with increasing numbers, every new user gets a higher number. This number is unique for the user and his session. In order to track the users streams, we also track the StreamIDs that the user might number himself. For example this format is commonly used: [unique user id]:[stream id]:
- 14:0 -> first stream of user with unique id 14
- 12:11 -> 11ths stream of user with unique id 12
reserved IDs
all Stream-IDs below 10 are reserved for special purposes. From 10 and up are the normal streams registered.
High level, abstract flow
Stream explanation by example of the character stream
the character stream is the stream that handles the data of the players person(avatar,character) in the game. It is used to create a person per player and to move it around the scene.
special events
- client lags -> lag can be detected on both ends by comparing data timings, there is currently no specific idea of what to do when the client lags.
- client disconnect without notice (connection breaks): the server notices the timeout or socket close and will send a MSG2_USER_LEAVE message to all other clients.
Internal structural details
notes about the diagram:
- normal arrow means inheritance, dotted arrow data flow
- bottom classes are example classes which inherit their base class
Example workflow how the character class works
there might be some missing bits, if you have comments or questions please ask in this thread.
class description for the diagram below:
- RoRApp: something in the other RoR code, used to visualize the need of creation
- CharacterFactory: factory that has control overall character instances.
- You cannot create a new instance of the class by yourself, only over the factory
- The Factory can change the state or delete any instance at any time
- it can contain factory specific methods that work with all instances
- Character: example class instance to be worked with
- StreamableBaseClass: base class methods that Character inherits from Streamable
- NetworkStreamManager: this Manager knows about all streams for all users. Its main work is to redirect the data flow between the Streamable classes and the network
- Network: the basic network interface. Simplified consists of a send loop, receive loop. No higher level functions should end up here.
- red arrows are handled automatically
- blue arrows require user coding additions
notes about the design
- the factory class will create all beam instances in the game, even in single player
- all classes/factories will know about the network state. In SP, no class will try to register streams or generate packages

