• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Ripiz

Networking engine design trouble

7 posts in this topic

Hello,

In my free time I'm trying to learn programming and I decided trying to make game should be good experience, therefore I picked MMOG (please no trolling). I've tried to find some networking library however I failed, so I decided to try and make my own one, or at least something that simplifies networking. I decided to go with semi-RPC way: non-blocking RPCs where return value is another RPC. However I ran into little design issue.

Lets say main loop on client looks like this:
[CODE]
void MainLoop() {
HandleInput();
UpdateFrame();
RenderFrame();
}

/* somewhere inside one of functions player sends data to server */
/* for example chat message, login request, etc */

// currently I planned it'd look like this:
string username = ...; // get input from GUI
string password = ...;
client->Call("Login", username, password);
/* Call() serializes parameters and sends them over network to server using sendto() function */

/* on server side function will be called */
void Login(string username, string password) {
if(database.FindAccount(username, password))
server->Call("LoginReply", "success"); /* where to send data? */
}
[/CODE]

Therefore right now I cannot seem create proper design that'd allow me to send reply back easily.
I was hoping someone could help me out with this issue. Maybe even whole idea is wrong and there are better solutions?

Thank you in advance.
0

Share this post


Link to post
Share on other sites
What do you mean "you tried to find anetwork library, but failed"? You didn't find any, or the ones you found where not fit for your project?

Did you check out RakNet? I used it before and it's pretty good.
0

Share this post


Link to post
Share on other sites
[quote][code]
/* where to send data? */
}
[/code][/quote]

A common approach is publish/subscribe (or observer pattern for non-network). Communication is bi-directional, but independent. Each end listens to messages and replies at leisure. Server looks like this:[code]// Client is created by server whenever a new connection is accepted. it then uses that class to deal with it
class Client {
// the rest
socket s;
}

List<Client> clients;

void onMessage(Client c, Message m) {
// decode message
// handle it
c->send(ReplyMessage);...
}[/code]Server and client here are free to send messages as they wish. If you need a request/response, include some type of tag into message. Can be a random number, hash code or some sequential identifier, something unique.
0

Share this post


Link to post
Share on other sites
Well RakNet is somewhat nice, but it costs money (commercial license);
Similar issue with Zoidcom ([url="http://www.zoidcom.com/"]http://www.zoidcom.com/[/url]);
HawkNL seemed just like simple wrapper to low level functions (socket(), listen(), send(), etc);
enet is just general networking lib (connection, disconnection, etc);
ZIG is a bit higher level, feature or two towards games (client_id in connection/disconnection/packets), however all received data falls into single function, that would still require major wrapper, but overall I think this one is best in the lislt;
There were more libraries but I cannot find them right now to tell what was unsuitable.

Antheus, thank you for advice. I'll try that approach.
0

Share this post


Link to post
Share on other sites
[quote name='Ripiz' timestamp='1332774646' post='4925373']
Well RakNet is somewhat nice, but it costs money (commercial license);
[/quote]

They offer a non-cost Indie license though... anyways, not trying to sound like a sales rep here. ;) If you want to build your own that's cool too.
0

Share this post


Link to post
Share on other sites
[quote]In my free time I'm trying to learn programming and I decided trying to make game should be good experience, therefore I picked MMOG (please no trolling). I've tried to find some networking library however I failed, so I decided to try and make my own one[/quote]

If you don't even know how to program, you are doomed to failure in this effort. Networking (or, in the general sense,) distributed systems, is a hard area of systems programming, which you typically don't even start learning about until several years in on a university computer science program -- for a reason.

Currently, it sounds as if you're not even at the point where you would be able to tell whether a library would be suitable or not. Starting with RPC is probably the first mistake -- that is not a generally useful approach for large, fine-grain distributed systems, for reasons that have been explained in literature.

I suggest you first learn to program, using something really simple, like Space Invaders or Tetris (this will still be pretty hard.)
0

Share this post


Link to post
Share on other sites
If you really really want to learn how to do network programming, I would suggest you install Unix first and than read the book Unix Network Programming by W. Richard Stevens. This is an awesome book which covers most of the BASIC aspects of Unix server side coding like Polling, Asynchronous I/O (crucial) etc.. If you than have a thorough understanding of how the basic stuff works you can use to high level libraries like Boost::ASIO , which leverage a lot of work for you and provide a simple but efficient interface to handle at least a couple of hundreds clients.
Of course you could use a dedicated library straight from the beginning but especially in a field like networking it is often necessary to have an understanding about whats going on under the hood. Especially when you need to customize stuff. The cool thing about studying unix sockets is that it will also tell you alot about how unix works in general. It is really an eye opener to get an understanding of file descriptors etc..
1

Share this post


Link to post
Share on other sites
[quote] install Unix first and than read the book Unix Network Programming by W. Richard Stevens[/quote]

I second this suggestion -- it's a great thing to do if you want to get into networking (and thus systems programming and distributed programming.)
Learning the UNIX environment, including the shell command line, is also a good way of getting a better understanding of how to automate systems and make them robust without operator intervention.
And it's easy to get started -- download an Ubuntu "live CD" and/or install as an application for Windows. Or use a virtual machine. Highly recommended.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0