GNetLib V0.0.0.3 (A Simple Java Networking Library)

Many multiplayer games have a lobby function to them. Is it possible to make a feature like that so the programmer does not have to write it but rather the library does a lot of it for us?

I would have no problem (Meaning desire wise) implementing this feature, could you elaborate on it a little bit more?

NOTE: I did want to keep this library small with only essential features included leaving the rest, like fancy features up to the user as GNetLib provides the functionality of doing so.

I think I’ll take a pause on implementing UDP and work on releasing V0.0.0.3 as implementing UDP has turned out to be very time consuming and V0.0.0.2 needs some work.

V0.0.0.3 will include:
A Server Monitor GUI to monitor network activity etc.
Fixed server-sided memory leak.
Fixed ‘hanging code’ when initializing a clients InputStream.
Cleaner & more documented code.

Hopefully I can upload V0.0.0.3 today :slight_smile:

What I really mean is the ability to make a client “become” the host, kind of like how online lobbies work.

A game with this feature, for example, would be Counter Strike: Global Offensive

This image can help clarify my idea:

http://biomes.host-ed.me/maxresdefault.jpg

[off-topic]

  • Love your signature ha, think I seen it while browsing java jokes XD
  • Seen blitzcrank in the screenie, love that game play it alot :slight_smile: (Bronze 2 LOL)
    [/off-topic]

On topic:
I don’t want to seem rude, while programming this library I’ve the desire in mind of it being “Small, providing essential features for users to make a networked single/multiplayer game”.

As I said in my previous posting on this thread, I’d like to leave the rest of the fancy programming/featuresup to the user of the library :slight_smile:

IE: Game lobbys etc
Although if more users request this features, I’ll oblige and it’ll be implemented ASAP.

EDIT: Just seen the chat in the screenshot, might wanna black that out of the screenie lol… :persecutioncomplex: :persecutioncomplex:

Thanks for clarifying ;D

I have been experimenting with the library, and I’m trying to get the debug log as a string, but I can’t seem to do so. How can I do that?

The “Debug log”?

Are you referring to the console logging? (GNetServer -> MSG)

Yes

At the moment there’s no logging system besides the standard java logging.

Which is done in GNetLib via:


void print(final String message) {
	if (debugging)
		System.out.println("GNetServer -> " + message);
}

void printERR(final String message) {
	if (debugging)
		System.err.println("GNetServer -> " + message);
}

Curious, why would you want to obtain the debugging message as a String if it’s meant for logging messages to the console?

I am making a GUI and I want to put the logs in a JTextArea, but the only way I can is if I get the log(s) as a string and then append it.

I don’t want to give you support that’s not valid :-, but take a look into re-routing the System.out and System.err to your own logging system, than have the output appended to your JTextArea.

Here’s a link on how to do so: http://unserializableone.blogspot.com/2009/01/redirecting-systemout-and-systemerr-to.html
(JTextArea/JTextPane example)

Hopefully it helps mate :slight_smile:

(In your case, hoping it will re-route GNetLib’s System.out/System.err also)

you could give support for returning a string anyway by simply changing void to String


String print(final String message)
{
	if (debugging)
	{
		System.out.println("GNetServer -> " + message);
	}
	
	return "GNetServer -> " + message;
}

String printERR(final String message)
{
	if (debugging)
	{
		System.err.println("GNetServer -> " + message);
	}
	return "GNetServer -> " + message;
}

now, if the user has debugging mode off, he can still gather the messages as well.

for the 4 line change, it is probably worth it more to satisfy the users in all scenarios.

maybe they want to filter the messaging system, by only displaying messages in the text area that are important to the server host, e.g. someone connected, someone disconnected.

Or be able to add/remove outputstreams that msgs are sent to. By default System.out/err, can add more or remove them.

Will be going this route :slight_smile:
Thanks for the suggestion BurntPizza, I get what you’re saying :stuck_out_tongue:

On another note:
Getting ready to upload V0.0.0.3!
Hopefully people find the Server Monitor GUI useful :slight_smile:

i sent a msg to you with me skype!

i would love to have some help with this libary!

when i implement it to a game i have i will add tween screen with libary picture so you need to
create one xD

When will v 0.0.0.3

Also @TehJavaDev:

Add me on skype: waleed.ahmad.ghazal

Rather busy this evening with family related affairs, when I get up in the morning I’ll remove any UDP related functions and release V0.0.0.3 with major bug fixes I found in V0.0.0.2.

Thanks for checking in :slight_smile:

NOTE: I’ll also be adding a custom logging system that’ll allow you to redirect the System.out/System.err to your custom stream to meet your needs.

Thank you so muchhh ;D ;D ;D ;D ;D ;D

Is there a way to kick one specific client from the server(I’m using ClientShutdownPacket by the way)?

My code:


if(packet.getPacketName().contentEquals("UserPacket"))
				{
					users.add(packet.getEntry("username").toString());
					String test = users.get(0);
					System.out.println(packet.getEntry("IP"));
					
					boolean kick = in.nextLine().contains("kick: ");
					  if(kick)
					  {
						  String[] x = in.nextLine().split(":", -1);
						  System.out.println(x[0]);
						  System.out.println(x[1]);
						  
							ClientShutdownPacket shutdown = new ClientShutdownPacket(client);
							client.connected = false;
							shutdown.addEntry("SHUTDOWN", true);
							
							client.sendPacket(shutdown);
							
					  }
							return;
				}