Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 16 of 16

Thread: Game Networking

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Game Networking

    Hello!

    I'm developing a game with a team, and I was wondering what sort of networking support we should use.

    At a basic level, it's a shooter where players would be able to chose from and enter multiple game rooms set up by other players, and each room would host a game. At the end of each game, player stats would be sent to a server and the player profile would be updated.

    What's the best networking method to use? Should the code be drawn from scratch or is there an API that suits these needs?

    Thanks!


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Game Networking

    There are several things to consider in the design:
    What kind of data: String, int, images, ??? would be sent between the PCs?
    What would be the source of the data? For example an image from a data base or directory.
    How frequently would the data be sent? Would the server need to save data between games?

  3. #3
    Junior Member
    Join Date
    Nov 2011
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Game Networking

    Well images are all going to be stored on the client, but I guess something like when Computer 1 fires a weapon, Computer 2 also needs to see the bullet. Is it best to do this directly between the two PCs or through a server?
    Yes, data would be saved after every game- scores, etc.
    Data would have to be sent every time a player performs an action.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Game Networking

    You wouldn't be sending "bullets" between the PCs. You'd create a message with some data describing the event/action and sent that. For example if you used three ints to describe the event. The first int would say this message is for a bullet, the next int would be the source of the bullet and the third int would be the target of the bullet.

    directly between the two PCs or through a server?
    It depends. Directly could keep the server simpler but could make the clients more complicated. You'd need to define your message sending/receiving protocols and see what the logic looks like.
    Last edited by Norm; November 29th, 2011 at 01:09 PM.

  5. The Following User Says Thank You to Norm For This Useful Post:

    Parsnips (November 29th, 2011)

  6. #5
    Junior Member
    Join Date
    Nov 2011
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Game Networking

    Ok, thanks! I guess I should stick with the default Java networking api?

  7. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Game Networking

    I should stick with the default Java networking api
    I'm not sure what you mean there. What other choices do you have for your project?
    Again it depends on what your requirements are and if you can find existing packages that will do what you want.

  8. #7
    Junior Member
    Join Date
    Nov 2011
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Game Networking

    I was wondering if something like Kryonet or other might be suited to my needs, but I've decided to write from scratch!

    That being said, as an aside, what's the best way for a client to run a procedure on a server?

  9. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Game Networking

    what's the best way for a client to run a procedure on a server?
    Sorry, I have no idea what the best way is. What are the criteria that determines "best"?

  10. #9
    Junior Member
    Join Date
    Nov 2011
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Game Networking

    Most efficient and universal!

  11. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Game Networking

    Those two criteria could be mutually exclusive.
    What about easy to use and cost?

  12. #11
    Junior Member
    Join Date
    Nov 2011
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Game Networking

    Sure, that could work!

  13. #12
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Game Networking

    Or How about most features and reliableness.

    Soon we'll need a spread sheet to list the features for each way of doing it. I've never needed one and don't have one.

  14. #13
    Junior Member
    Join Date
    Nov 2011
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Game Networking

    I just need to execute a procedure on a server using only primitive data.

  15. #14
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Game Networking

    Does the data come from the client? How much data is there?
    Perhaps you need to define a protocol between your client and its server.
    In the message, the first item would be the message type that tells the server what data is to follow and what the server is expected to do with it.
    Make a list of all the things the client would want to ask the server to do and what data would need to to with that request. Then you need to define the types of messages that the server would send back to the client.

  16. #15
    Junior Member
    Join Date
    Nov 2011
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Game Networking

    I know what sort of data I want to send and receive, I just need to know the actual code that executes a method on the server with the given data.

  17. #16
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Game Networking

    If you write the server code, then it is 100% under your control. You would call the method with the data in the normal manner.

    If someone has written the server code, then you need to read the doc for the server and see how to make it do what you want it to do.

Similar Threads

  1. Java Networking Without Port Forwarding
    By bgroenks96 in forum Java Theory & Questions
    Replies: 4
    Last Post: September 6th, 2011, 03:07 AM
  2. networking in java
    By sridhar in forum Member Introductions
    Replies: 1
    Last Post: October 4th, 2010, 11:11 AM
  3. networking problem
    By anurupr in forum Java Networking
    Replies: 0
    Last Post: March 15th, 2010, 04:26 AM
  4. [SOLVED] java networking
    By renu1 in forum Java Networking
    Replies: 0
    Last Post: March 12th, 2010, 12:33 PM
  5. advanced java networking help/theory
    By wolfgar in forum Java Theory & Questions
    Replies: 2
    Last Post: February 7th, 2010, 07:02 PM