Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (497)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Moving from a String based approach?  (Read 2050 times)
0 Members and 1 Guest are viewing this topic.
Offline CTucker1327
« Posted 2014-07-28 16:20:06 »

I want to make my networking better. I'm working with the Netty API and I've written a Client/Server application that breaks apart a String that's been sent over the network and figures things out. An example of my Login packet would look like this.

1  
[1]Username@Password


Where [1] is the packet Id, and then the user/pass (all data, really) is split by the character '@'

1  
2  
3  
4  
5  
6  
7  
out.build(176, player.getSession())
                .writeByte(recoveryChange, ValueType.C)
                .writeShort(messages, ValueType.A)
                .writeByte(memberWarning ? 1 : 0)
                .writeInt(lastLoginIP, ByteOrder.INVERSE_MIDDLE)
                .writeShort(lastLogin);
        out.sendPacket();


Here is an example of what I'm looking for. Something that creates a packet like such. I've been looking and looking, and I have a github for a server project that uses this type of networking, but I don't understand it.  I'm looking more so on tutorials/documentation for this.
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 799
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #1 - Posted 2014-07-28 16:47:11 »

DataInputStream, DataOutputStream.

Better: KryoNet

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline CTucker1327
« Reply #2 - Posted 2014-07-28 20:47:05 »

KyroNet is better than Netty?

Could you please provide more information? I can't find any benchmark comparisons, etc.

The reason I chose Netty was due to the fact I use a C# based client.
I was reading the KyroNet didn't support C# Clients, as it used a special network layer? Not sure, never got into it.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline jmaasing

Junior Newbie





« Reply #3 - Posted 2014-07-29 07:14:32 »

So you are looking for something that can serialize java objects to a compact binary representation that is also serializable to from C#? I would guess that you either hand-roll the protocol: i.e. on both the java and the C# side know that to read an int you need to read 4 bytes (or whatever). DataInput/OuputStream is reasonably compact and have a well defined byte layout of primitives so that's a good tip from Riven.

Other options would be to use google protocol buffers https://developers.google.com/protocol-buffers/ and try to find a C# translation for that.
Kryo is a very good serialization framework that is used by KryoNet but I'm not sure how easy that would be to read in C#.
Offline Mike

JGO Wizard


Medals: 76
Projects: 1
Exp: 6 years


Java guru wanabee


« Reply #4 - Posted 2014-07-29 14:07:50 »

I'm busy with doing exactly this, and I find Kryonet awesome so far. I recommend it without a doubt Smiley

Mike

My current game, Minecraft meets Farmville and goes online Smiley
State of Fortune | Discussion thread @ JGO
Offline alesky

Junior Member


Medals: 3
Exp: 15 years


mmm....


« Reply #5 - Posted 2014-07-29 15:27:57 »


if your implementation is a serve centric
where each client will keep a connection whit the server, you can chose a standard interchange protocol

for example you can use CORBA or SOAP

this protocols keep you far for the real technical issues connection, serialization, deserialziation
what you have to do in your code is just create the data that will be transfer

there are several implementation for both the protocols in JAVA or C#, and in case you can integate easily also whit other languages if u need in future

 





Offline Riven
« League of Dukes »

JGO Overlord


Medals: 799
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #6 - Posted 2014-07-29 15:42:48 »

I would pick plain-text over CORBA/SOAP any day.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline kevglass

JGO Kernel


Medals: 164
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #7 - Posted 2014-07-29 15:44:58 »

CORBA/SOAP/RMI/RPC would be very poor choices here. Generic object serialization is going to bite you very quickly. Kyro is definitely a good way to go here, if not just encode your pure data encoding isn't too bad - wrap it up a bit and you'd probably be fine.

Cheers,

Kev

Offline ClaasJG

Junior Member


Medals: 4



« Reply #8 - Posted 2014-07-30 08:46:32 »

Kryo is a very good serialization framework that is used by KryoNet but I'm not sure how easy that would be to read in C#.


I would use kryonet. I like its api but not Kryo. In a pure java enviroment it is awesome but hard to work with in other languages.

But kryonet supports custom serialization (http://goo.gl/ZMQu5Q). I would recomment to look at bson and http://goo.gl/iLeJJG.

ClaasJG

My english has to be tweaked. Please show me my mistakes.
Offline delt0r

JGO Knight


Medals: 27
Exp: 18 years


Computers can do that?


« Reply #9 - Posted 2014-07-30 11:49:03 »

Whatever you do, DON'T use CORBA. You would be better off stabbing yourself in the face with a blunt axe.

Yes i have used it extensively in the telecoms i once worked at. God i hope they moved on by now.

Seriously what is wrong with plain text. It is much much easier to debug since network inspection tools work out of the box. Performance is almost never needed and even if it is in the future i would always have a plain text fallback/debug mode.
 

I have no special talents. I am only passionately curious.--Albert Einstein
Pages: [1]
  ignore  |  Print  
 
 

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

BurntPizza (25 views)
2014-09-19 03:14:18

Dwinin (39 views)
2014-09-12 09:08:26

Norakomi (68 views)
2014-09-10 13:57:51

TehJavaDev (93 views)
2014-09-10 06:39:09

Tekkerue (47 views)
2014-09-09 02:24:56

mitcheeb (69 views)
2014-09-08 06:06:29

BurntPizza (51 views)
2014-09-07 01:13:42

Longarmx (38 views)
2014-09-07 01:12:14

Longarmx (44 views)
2014-09-07 01:11:22

Longarmx (40 views)
2014-09-07 01:10:19
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!