Title: Networking Post by: Job on August 01, 2005, 02:29:59 am I've just realized something that makes client/client connections problematic. I had this timeline:
Code: . User A starts the application. It may not always be possible to get an ip address for the client machine. Suppose you're behind a router, which you probably are, and want to play a multiplayer game, then you likely have a local (internal) IP address (like 192.168.x.x) assigned to you by your router. The router is the one who has the external IP address. In this case if i wanted to connect directly to your computer, from my computer, i can only use the external IP address (the internal address is useless), and so i can only reach your router. Most routers are not set up to forward incoming requests onto the machines in the local network, let alone forward the correct port. What this means is that it may not be possible for a client to connect to another client via IP addressing, hence there must always be a server in the middle. My plan is to use a server as a dispatcher. With this approach, both clients, A and B, connect to the server. Then, since a client can't directly talk to the other client, whenever A wants to send a message to B it sends the message to the server and the server is the one who actually sends the message to client B. This, i hope, won't really load the server up since it will only forward the messages, which involves minimum computation. Any thoughts on this? Title: Networking Post by: Elvenfyre on August 01, 2005, 02:19:01 am Yeah that's the right way to build something that will be easy for people to install and start playing right away.
Creating a direct connection would be an easy way to test out the game between the likes of ourselves - but if you feel you're capable of making something better (like that), then by all means do :) Title: Networking Post by: Job on August 01, 2005, 02:34:57 am I'm just thinking about the other guys, Ty & Co, who may not have a server available (a web host will probably not do it since you need to run your own server software and connect to ports other than the http port). You can use my server if you want, as long as your software doesn't crash it :P. I'm actually very much considering getting a new server to devote completely as a web host, that one you can crash all you want.
Title: Networking Post by: Ty on August 01, 2005, 10:21:24 pm I think I'll use a peer to peer model to begin with, as that means anyone with the game can act as a server. The main problem is preventing cheats, so I'll have to look at that.
Title: Networking Post by: Job on August 02, 2005, 03:07:23 am A great advantage of Java is how easy it is to use multi-threading which significantly improves server performance.
Title: Networking Post by: Elvenfyre on August 02, 2005, 11:32:49 am Job, Devlyn has said if we keep it open source we could use BABS for the battle engine.
?? Title: Networking Post by: Devlyn on August 02, 2005, 01:29:10 pm Yup, you are free to edit or use parts of the BABS code wherever you like. I would appreciate it of course if you'd put me somewhere in the credits, but I guess that's only logical ;).
Title: Networking Post by: Job on August 02, 2005, 04:12:50 pm Thanks Dev, i'll need the source code for BABS once i'm finished with this. I made a simple server and a simple client. As it is, after i start the server and connect a few client instances it's easy for the clients to communicate with the server and i can even broadcast messages from the server to the clients.
However i just found out about the JXTA protocol, a P2P protocol which is supported by Java and is implemented like the Java Sockets that i'm using right now. The purpose of the JXTA protocol is to allow client-client connections between computers that are unaddressable (either because of a firewall, NAT, etc) so i'm back to the original timeline. Like Ty i'm also going P2P. Title: Networking Post by: Elvenfyre on August 03, 2005, 02:51:53 am Sounds great, can't wait to hear more : )
I'll keep working on balances and imbalances. I've been thinking of ways to implement classic spells into combat. So stuff like a guy who when he hits the opponent, their agility decreases, or he gains some % of health back and all sorts of stuff. (and also how these would be implemented in a BABS sense) One other thing that I thought of if it's PvP, is a time limit between moves. You don't want to have to rush your move - but then again you don't want to be waiting 5 minutes for your opponent to make one move. If you limit each move to a maximum of 60 seconds, I really feel this is enough(don't move in this time, you get a warning at 10 seconds left, and then you lose your turn) - because with 10 units on your team, to move each unit once, that's 10 minutes. 10 minutes should be more than enough to check out your opponents units and so on. Title: Networking Post by: Job on August 03, 2005, 05:37:49 am It's probably going to take a while to figure this JXTA thing out. It took me most of today just to figure out how to install the open source libraries under Eclipse, but i ran some demos and they work.
Title: Elvenfyre Please Read Post by: Peter van Dalen on August 03, 2005, 07:27:09 am Elvenfyre,
Have you received my e-mail , which I sent last monday ? :? Title: Networking Post by: Elvenfyre on August 03, 2005, 10:49:53 am Yeah I have Peter, sorry that I didn't reply! I really should have.
Just had no time to play with the images and turn them into something yet. Great work though! How far are you on sprite models? Would be a really awesome to create some menu backgrounds with screenshots of a couple of guys in one of the landscapes with swords crossed.. or an archer firing at a mage who has a spell ready kind of thing. I'm just not so sure what to do with these images you've sent me, I'm sure I'll come up with something. Title: Networking Post by: Peter van Dalen on August 04, 2005, 09:04:44 am Phew , I was worried there for a minute. I thought I made a typo in your e-mail adress :lol:
Happy to know you like the screenies. :D Sorry I can't give you an estimate of when my models are finished. They are boned meshes for now and still need a lot of rigging. I haven't begun texturing :( . If you need more screenies, just let me know ok? :) Title: Networking Post by: Job on August 05, 2005, 03:12:35 am I made another client and server, this time using the JXTA protocol. Took me alot of work to understand how to work with JXTA but i finally got it.
The way it works is: Server: . Creates a Peer Group named SFMP (if it doesn't exist). . Joins the group SFMP. . Creates a pipe (used in P2P connections) with a pipe id generated by a username. . Creates a JXTA server socket from the pipe above and listens for incoming connections. Client: . Creates a Peer Group named SFMP (if it doesn't exist). . Joins the group SFMP. . Creates a pipe with a pipe id generated by the username corresponding to the user it wants to connect to. . Creates a JXTA client socket from the pipe above and connects to the server. . Sends 1824 messages each of size 66 Kb to the server, which comes to about 120Mb. The client above takes between 1 and 2 minutes to send 120Mb to the server which is pretty fast even if i'm on DSL and sending from my computer to my computer. Title: Networking Post by: Elvenfyre on August 05, 2005, 05:04:53 am That's awesome progress!
Wow man excellent. I guess the next step is listing different clients waiting on the server and choosing which one to make a connection with, the (users)negotiation of the connection - and then the connection itself allowing the two people to let's say, chat to each other and end the session when they're ready. :E I dunno though, you tell me! Title: Networking Post by: Job on August 05, 2005, 05:23:38 am I already have the code that gets the peers in a given peer group, so i want to put up a simple interface that allows a user to choose which peer to connect to, and then bring up a simple chat app. I just need some time to put it together, but i'm not expecting any complications.
I also download the latest BABS release and it looks pretty sweet, good job Dev. Title: Networking Post by: Devlyn on August 05, 2005, 02:42:30 pm Thanks ;). Hopefully the source code isn't overly filthy and messy for your taste :).
Title: Networking Post by: Job on August 05, 2005, 06:39:40 pm It's all right, i'm pretty good at cleaning up and organizing code. I'm glad i can use your engine because, though i'm very confortable with the language, i have zero experience in dealing with graphics in Java, so it saves me the time of going through the API.
By the way, here is a P2P chess game built in Java using the JXTA protocol: http://chess.jxta.org/ If they can do it, we can do it. :) Title: Networking Post by: Job on August 06, 2005, 04:36:42 am Seeing as peers will be represented by a username, and in order to guarantee username uniqueness, i'll have to implement a login system.
I was thinking of having the application authenticate at the Shining Source, this way YOB members won't have to register to test the game and i won't have to build a login/registration system. Ty is it possible for you to write a script that takes in a username and password (via POST), tries to login and prints true/false if the login succeeds/fails? This would be as secure as a regular browser login. Title: Networking Post by: Ty on August 06, 2005, 10:05:56 am Yep, that's no problem.
Title: Networking Post by: Elvenfyre on August 07, 2005, 01:27:08 pm Wow things are progressing really well :D
Title: Networking Post by: Ty on August 07, 2005, 07:05:37 pm Done.
This page takes two POST vars - "username" and "password", and will verify them. It will either return "true", or "false" followed by a line break and an error message. Both fields should be sent plain text (i.e. the password should not be encrypted), but this can change at a later date should you wish. Any problems, let me know. Title: Networking Post by: Job on August 07, 2005, 08:48:39 pm Great, i'll put it to use soon. I suffered a setback when i found out that the same application can't be running both a client and a server, hence it can't both be listening for connections and attempting to connect to some peer. To solve this peers will choose to either connect to waiting peers or wait for peers to connect, but this can be changed at any time.
I had to recode some stuff, but i think it was for the best since now i have my own custom client/server sockets, i made them really easy to use: ServerSocket: void listen() void send(String msg) ClientSocket: void connect(Peer) void send(String msg) I also created the interface SocketListener: void onConnect() void onReceive(String data) (I even worked out a handshake protocol so that each peer can be certain that the other peer is running the right application) The above works very nicely so a chat app is really easy to make. The things that i need to get done before we have a P2P Chat app are: . Figure out how to send Post data with a socket. :P . Create a login interface . Create an interface that shows waiting peers, and allows users to choose one to connect to . Create a chat interface . Compile the program. Title: Networking Post by: Job on August 09, 2005, 03:27:14 pm Of the above all that is left to do is:
. Create the chat interface. . Compile the program. If everything goes smoothly i'll have this ready either today or tomorrow. Title: Networking Post by: Job on August 10, 2005, 08:33:27 pm I got it working. I'm going to wait to release a demo because there's some bugs i need to fix and some behaviors i want to add (connection timeout for example).
The chat worked fine between my computer and my brother's. I have two screenshots of it here (the interface was roughly put together): ![]() ![]() By the way, i created a user DemoUser with password "demo" just for testing purposes, in case your wondering who that is. :P Ty edit: Made post pretty ;) Title: Networking Post by: Elvenfyre on August 11, 2005, 12:00:18 am That's so cool!
Good stuff! One new thing I've thought about, especially with testing - is to time sync everyone, and give an idea of what's possible. Let's talk about time in GMT, since I'm not sure what zone you're in. So my day starts around 2200GMT and ends 1400GMT I can take time out of the beginning, middle OR end of the day usually just not all three ;) I can also stay up late or wake early if it's important, and just move my stuff around cos I really want to see this go somewhere. :) Well done, once again, I'm getting excited! Title: Networking Post by: Elvenfyre on August 17, 2005, 01:58:47 am :)
Title: Networking Post by: Job on August 17, 2005, 03:16:35 am I've been trying to eliminate some of the bugs in the prgoram. I just fixed a rough one that was causing the program to deadlock. Apparently if you use threads with Swing components there's a chance the program might deadlock.
An interesting thing came out of this. There was another bug that prevented the chat window from scrolling down whenever text was appended if the chat window did not have the focus. I later found out that this is a bug in Java 1.5.0 (so not my fault), and that there's no current workaround for it. Here's the link to the bug: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5003402 The interesting thing is that the code that i used to fix the bug that was causing the deadlock also fixed the scrolling bug. I posted a comment in the link above with the code i used, to let other developers know. But there's still some other stuff to fix. Title: Networking Post by: Job on August 23, 2005, 05:28:31 pm I've gotten to a state right now where everything is running pretty smoothly. The chat app supports multiple connections, it can detect when a connection is remotely closed, it can restart a connection, etc.
I'm thinking of releasing it, once it's finished, as the "Shining Source Instant Messenger" :P . I need to think of a proper interface. I think i'll just model it after some popular instant messenger's interface like Yahoo, AIM... etc. ;) By the way, i know it's not really necessary to have a Shining Source messenger since everybody here probably already has one they can use, it's just the groundwork for a multiplayer game. :) Title: Networking Post by: Elvenfyre on August 24, 2005, 02:22:02 am Sounds like a plan.
So... what's next?? :D Title: Networking Post by: Akir on August 24, 2005, 03:30:47 am Storyline?
... Nah. But now that I think about it, Why not use a Shining Messanger? That way you can keep the game fullscreen and talk with your friends. And I've a good idea to go with it: Use SILC. It's secure, and Open Source. All you have to do Is manipulate some SILC client's source, and you're home free. Title: Networking Post by: Elvenfyre on August 24, 2005, 04:16:26 am uhh...
Title: Networking Post by: Elvenfyre on August 24, 2005, 04:23:25 am I was thinking more game start, battle creation using BABS and (for first implementation) set teams, battle turn swapping, battle win by one player/stalemate options, game end - with the chat running throughout with your opponent if possible.
Definitely up to Job as to what he wants to go for, the PvP or a MP(co-op)vE or what, whether he wants to do any more at all. Title: Networking Post by: Akir on August 25, 2005, 03:51:49 am Well, If Project Candlelight isn't as feasible as I am hoping, I might adopt it :P
Title: Networking Post by: Job on August 28, 2005, 03:28:42 pm I left a chat instance running at my computer and took another one to a computer outside the local network of the first one and they didn't detect eachother :cry: . So i need to do some "tweaking".
|