Asynchronous updates

Discussions related to programming Transport Empire.

Moderator: Transport Empire Moderators

Post Reply
Hellfire
Transport Empire Developer
Transport Empire Developer
Posts: 699
Joined: 03 Feb 2003 09:30
Location: Back at the office

Asynchronous updates

Post by Hellfire »

Clients register for updates at the server. What does this mean? Whenever the player is looking at a piece of the map, the client says "I'm looking at the region from (x, y) to (x', y')." The server will then send updates to that client, whenever something changes in the given region.

If the user scrolls the view, then an update should be sent to the server

Requirements:
  1. Registrations must be uniquely identifyable.
  2. The client must be able to update and delete a registration.
  3. Clients can have more than one registration.
  4. Whenever a piece of the map changes, the updates are sent to all clients that have registered that piece of the map.
  5. Updates are queued and sent in bulk. (this saves bandwith)
If I combine requirements 1, 2 and 3, then it could be wise to let the client create its own ID numbers for registration. Consequences:
  • The server can uniquely identify a registration by the combination of the PlayerID of the client and the registration ID.
  • Clients can assign registration ID's at will. They do not have to request unique ID's at the server. (i.e. it's faster)
  • Clients assign registraion ID's to views and delete them whenever a view is closed.
Feel free to contact me over Email! My current timezone: Europe/Amsterdam (GMT+1 or GMT+2)

Code: Select all

+------------Oo.------+
| Transport Empire -> |
+---------------------+
[ General TE Discussion ] [ TE Development ] [ TE Coding ]
Under construction...
User avatar
Vaulter
Traffic Manager
Traffic Manager
Posts: 185
Joined: 21 Dec 2004 05:35
Skype: andrey-zaharov
Location: St. Petersburg, Russia
Contact:

Re: Asynchronous updates

Post by Vaulter »

Yes, this make sense.

A simple RPC service, with following definitions:

Code: Select all

package protocol;
/// to really makes clients dunno nothing about server
/// we need to separate this file to server.proto client.proto and common.proto
// <editor-fold defaultstate="collapsed" desc="messages">
message GeneralResponse {
    optional int32	code	= 1 [default = 0];	    ///<error code, 0 if no
    optional string	text	= 2;			    ///< status text if any
    optional bool	close	= 3 [default = false];	    ///< client should close connection
};

message ClientRequest {
    required string	login	    = 1;   ///< some identifier of client.
    optional string	password    = 2;   ///< optional password if game is multiplayer
};

message ClientResponse {
    required	GeneralResponse	response    = 1;
    optional	ClientID	client	    = 2; ///< authorized ticket to use
};

message ClientID    {// identificator. can be used for fast session validation
    required	fixed32		clientID    = 1; ///< hash of client to use
    optional	string		ticket	    = 2; ///< session ticket
}

/// coordinates in plain map dimensions
message Viewport    {
    required	    sfixed64	x   = 1; ///< coordinates of the world
    required	    sfixed64	y   = 2; ///< coordinates of the world
    enum    ViewSize	{
	SMALL	= 1;
	MEDIUM	= 2;
	LARGE	= 3;
    } // but I prefer some distance number
    optional ViewSize viewsize		= 3	[default = MEDIUM]; ///< or as integer in coords
    optional sfixed64	iviewsize	= 4;  ///< or in parrots
};


/// client register viewport which can be several per client
message RegisterViewportRequest	{
    required	ClientID    client	= 1;
    required	Viewport    viewport	= 2;
};

message	RegisterViewportResponse {
    required	GeneralResponse	response	= 1;
    optional	fixed32		viewportID	= 2; ///< id of viewport. can be individual for client
}

message ChangeViewportRequest	{
    required	ClientID    client	= 1;
    required	fixed32	    viewportID  = 2;
    required	Viewport    viewport	= 3;
} // answer is RegisterViewportResponse

message UnregisterViewportRequest {
    required	ClientID	client		= 1;
    required	fixed32		viewportID	= 2; ///< id of viewport. can be individual for client
} // answer is RegisterViewportResponse

//also current players, map, vehicles and so on packets HERE...
// </editor-fold>

// <editor-fold defaultstate="collapsed" desc="services">
service	clients	{
    rpc	Register    (ClientRequest) returns (ClientResponse);
    rpc Unregister  (ClientRequest) returns (ClientResponse);
    rpc RegistreViewport    (RegisterViewportRequest)	returns (RegisterViewportResponse);
    rpc ChangeViewport	    (ChangeViewportRequest)	returns (RegisterViewportResponse);
    rpc UnregisterViewport  (UnregisterViewportRequest)	returns (RegisterViewportResponse);
}
// </editor-fold>
works for me!
soon i will able to register clients
Post Reply

Return to “Transport Empire Coding”

Who is online

Users browsing this forum: No registered users and 5 guests