Page 3 of 7 FirstFirst 12345 ... LastLast
Results 21 to 30 of 66

Thread: Game Network Engine

  1. #21

    Game Network Engine

    Quote Originally Posted by techomange
    UDP is connection less so there is no way of knowin g when a UDP client is no longer sending data. Only with TCP can you detect droped connections etc.

    Getting the remote UDP port is trickly in most netowrk libraries (I know it's a pain in SDL_Net) I always got round this by sending on a known port but firewalls don't always make that easy, or send the port to send info back on to the server in the first "handshake" mesages.

    Some thing else I do is to use TCP to connect to the server and login, then use UDP for all the time critical information. Taht way if the TCP connections drops you can handle that and remove that client from the UDP client list as well.
    I do the same thing with TCP, and for UDP ports of clients (the client sends their port via TCP). Plus if the client cant use UDP for some reason, it reroutes traffic to TCP.

    Indy doesnt fully detect TCP disconnects (thats what i meant at first). Even if you ask it "TCPClient.Connected" it can return true while the connected has been broken or timed out. I purchased an Indy support package (recommended) and they told me that we have to send keep alives and queries to verify TCP connection.


  2. #22

    Game Network Engine

    I got the Indy Support Documentation, it was very helpful.

    So is it a good idea to have this new engine use TCP to handle the initial handshakes/logins/important messages but to use UDP for messages that are very frequent :?:

    I did like the feature list of you AIR engine, especially the sync object stuff.

    I have been thinking about how to make objects that automatically send changed data over the net to it's twin on the server. I did some tests using RTTI to serialize published properties to XML (binary would be better) and then rebuild the object from the serializer data, but I'm not sure if it would be as quick as a virtual merthods that is just overridden in the decendent classes.
    <A HREF="http://www.myhpf.co.uk/banner.asp?friend=139328">
    <br /><IMG SRC="http://www.myhpf.co.uk/banners/60x468.gif" BORDER="0">
    <br /></A>

  3. #23

    Game Network Engine

    Quote Originally Posted by technomage
    I got the Indy Support Documentation, it was very helpful.

    So is it a good idea to have this new engine use TCP to handle the initial handshakes/logins/important messages but to use UDP for messages that are very frequent :?:
    Well, im not sure if its a good idea or not! There is a case for and against it. If i startched from scratch I would probably just go for UDP. This is my first attempt at network coding.

    I did like the feature list of you AIR engine, especially the sync object stuff.

    I have been thinking about how to make objects that automatically send changed data over the net to it's twin on the server. I did some tests using RTTI to serialize published properties to XML (binary would be better) and then rebuild the object from the serializer data, but I'm not sure if it would be as quick as a virtual merthods that is just overridden in the decendent classes.
    I'm using virtual methods, I find from a coding point of view its quite easy. Plus there may be some data or complex logic you want to sync that isnt possible from a property. Also consider some objects might only have certain data that needs to be changed alot vs just on the initial sent. The position changes quite frequently but you only need to send the color (or whatever property) of it once.

    For every object I put a Handle (unique integer) that is used for the clients to match obj with the server. If the client recieves a packet with a handle it doesnt know about, then the client requests a full update about that object. Thats a good way to make sure all your obj are being sent over UDP. I've avoided completely the sequential numbering of UDP packets and checking for out of order or missing packets, nor storing packet history on server, because basically take the assumption that any UDP data is not important because it may be overwritten by the next packet anyway. And if it isnt, the client will notice something fishy and request a new packet. Each object gets a time stamp from the last server update, plus a change counter. If the object has Changed and the time stamp is getting old, then the object is changing on the client improperly (although we do want to make sure the obj can change for prediction purposes), so the client again asks for a resync via the obj handle. This happens alot if you bump into a stack of boxes or some other unpredictable physics circumstance. I'm not sure what kind of network you want, but with 3d realtime physics this is the way I went to sync it.

    Big drawback if you use virtual methods then you are restricting because your users have to inherit from your code (and there is no multiple inheritance in OOP)

    heres an outline of the network stuff in AIR:
    Code:
    AIRSyncObject = Class&#40;AIRObject&#41;
    private
      fSyncStamp&#58; integer;
      fChange&#58; integer;
      fPredictable&#58; boolean;
      fExtraChanges&#58; string;
    protected
      function GetChanged&#58; boolean;
    public
      Constructor Create; override;
      Destructor Destroy; override;
    
      // time of last sync &#40;for client/server synchronizing&#41;
      property SyncStamp&#58; integer read fSyncStamp write fSyncStamp;
      // changes?
      property Change&#58; integer read fChange write fChange;
      // changed<>0
      property Changed&#58; boolean read GetChanged;
      // extra change info for packets
      property ExtraChanges&#58; string read fExtraChanges write fExtraChanges;
      // is this client-side predictable? &#40;wont send updates if true&#41;
      property Predictable&#58; boolean read fPredictable write fPredictable;
      // returns true if the engine should network this &#40;default&#41;,
      // false if not ... such as smoke effects, menus, etc
      function  Networked&#58; boolean; virtual;
      // network
      function  FullPacketOut&#58; string; virtual;
      procedure FullPacketIn&#40;const Packet&#58; TStrings&#41;; virtual;
      function  ChangedPacketOut&#58; string; virtual;
      procedure ChangedPacketIn&#40;const Packet&#58; TStrings&#41;; virtual;
      // change data
      procedure ChangeIncrease; overload;
      procedure ChangeIncrease&#40;aAmount&#58; integer&#41;; overload;
      procedure ChangeIncreaseMax;
      procedure ExtraChange&#40;const ExtraMsg&#58; string&#41;;
    end;
    hope that gives u some ideas.


  4. #24

    Game Network Engine

    That is really helpful, the Sync objectsd looks quite comprehensive.

    I think it should be possible to not force users to inherited from TSyncObject, does Free Pascal Support Interfaces on all platforms? If so that might be a good way around the problem, as objects that want to be sync'd just need to support the ISyncOBject interface.

    So who would use this engine if it was based on Indy? I got the impression some people are in favour of writing this engine from scratch, which is a fair point but I for one am not a Networking expert so using Indy which has already tackled most of the platform specific issues seems to me like a good idea.

    So where do we go from here....

    I will attempt to draw up a class heirachy on top of Indy. For example a "TGameServer" for example will derive from TIdUDPServer etc. Then we can split the work up into well defined packages and those of you who want to help out will work on a package (which will probably contain 1 or 2 classes)

    I will also try and think of a good name for this "project"
    <A HREF="http://www.myhpf.co.uk/banner.asp?friend=139328">
    <br /><IMG SRC="http://www.myhpf.co.uk/banners/60x468.gif" BORDER="0">
    <br /></A>

  5. #25
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Game Network Engine

    Thanks for the quick 101 on the TCP/UDP issue.

    Perhaps only using TCP for that initial 'handshake' would be best. Just to get all your network configuration options set. From there on UDP all the way it seems, is best for network play. I'm sure it's users will be happy for the extra speed because of it. Of course there are options and settings you can put in for some of their own specific preferences.

    A visual chart or the initial heirachy would be nice to get our bearings. I'm a visuals kinda guy. Like to 'see' everything.

    Oh, and I'm all for using Indy. Heck we can go nuts with all the extra options is has. mini-HTTP server to host game stats, mini-FTP server for game patch updates, IRC channels for chat rooms in the multiplayer lobby areas, etc...
    Jason McMillen
    Pascal Game Development
    Co-Founder





  6. #26

    Game Network Engine

    Might be worth have a look at this as well - http://www.gamedev.net/reference/pro...s/shavingping/
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  7. #27
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Game Network Engine

    :lol: You know... I was looking at that just the other day. Was thinking hmm... I should post this in PGD's Library.
    Jason McMillen
    Pascal Game Development
    Co-Founder





  8. #28

    Game Network Engine

    Quote Originally Posted by technomage
    So who would use this engine if it was based on Indy? I got the impression some people are in favour of writing this engine from scratch, which is a fair point but I for one am not a Networking expert so using Indy which has already tackled most of the platform specific issues seems to me like a good idea.
    Uhm, i wouldn't use it if it depends on Indy. It's too big for a dependancy.. Also, it's component based which is something unuseful and wasteful for most games.. I'll be happy to use SDL_Net becouse it's very easy and becouse i already use SDL, but of course i can't hope you all agree or use sdl For most of you a DLL is not welcome i think
    There's also the library i posted, synapse. Anyone gave it a shot? It's like indy but more lightweight and class-based instead of component-based.. Maybe we could just use the UDP classes.
    Or we can develop a base UDP library. The socket api are easy enought to use, i've used TCP sockets directly for a long time, and udp are easier.

    Anyway, my needs for a network library are:
    - sending normal UDP packets.
    - sending reliable UDP packets.

    for the second point i think we could implement some very simple aknowledge system. Note that just very rare packets will need to be reliable (for game setup), so there's no need to have ultra performances.. Just a simple acknowledge system would do.

    If you want to implement more advanced features, such as chat rooms and game setups, that's good, but it should be possible to just use the basic sending/receiving capabilities. They could be like two separated libraries, one on top of the other.

    These were my two cents
    If you save your data in a proprietary format, the owner of the format owns your data.
    <br /><A href="http://msx80.blogspot.com">http://msx80.blogspot.com</A>

  9. #29

    Game Network Engine

    Can you post the link for synapse here? Is it thread safe?

    I have to admit I have played with SDL_Net, my main reason for avoiding it at the moment is not because of the extra DLL but becasue of the threading issue, SDL_Net is not Thread Safe. I also wouldn't want to tie anyone wanting to use this library to an external dll, people using DirectX might not want to have to ship SDL_Net and SDL with the app (SDL_Net depends on SDL).

    The Threading issue is the biggest issue though. Any high performance networking system needs to be multi threaded.

    My personal preference is a library that is pascal based to there are no external dependancies. Indy can be used in a class based mode (I use it like that all the time).

    I guess we could start from scratch, but my knowledge of dealing with sockets on the various plattorms (windows, linux, FreeBSD0 is very limited.
    <A HREF="http://www.myhpf.co.uk/banner.asp?friend=139328">
    <br /><IMG SRC="http://www.myhpf.co.uk/banners/60x468.gif" BORDER="0">
    <br /></A>

  10. #30

    Game Network Engine

    Indy doesnt have to use drag-n-drop components, you can create everything dynamically. There is overhead tho

Page 3 of 7 FirstFirst 12345 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •