Welcome, guest! Please login or register.

    * Shoutbox

    RefreshHistory
    • wodkode: shut it down or fix it
      August 20, 2017, 10:11:28 PM
    • wodkode: dude i cant goto no links on here from google
      August 20, 2017, 10:11:13 PM
    • Dell: Greetings
      August 20, 2017, 11:56:30 AM
    • FaTe_Of_GoDs: You guys have an offline client?
      August 20, 2017, 03:25:13 AM
    • ASDss: where do u download source and clients now
      August 18, 2017, 10:39:31 PM
    • ASDss: yo
      August 18, 2017, 10:39:20 PM
    • dan v jad: click me 4 da fun ;)[link]
      August 18, 2017, 04:39:58 PM
    • stCky: Palidinho is your OpenGL (was it OpenGL?) stuff open source anywhere?
      August 16, 2017, 09:07:22 PM
    • Travas:BUILD THE WALL
      August 15, 2017, 09:28:49 PM
    • Travas: i have ass cancer
      August 15, 2017, 09:23:29 PM
    • stCky: what are the fudge are you tryna ask?
      August 15, 2017, 08:21:35 PM
    • bader: what are the rsps community alive ?
      August 15, 2017, 05:46:16 PM
    • bader: yo guys
      August 15, 2017, 05:46:08 PM
    • Spacehost:[link] Updated our thread :)
      August 15, 2017, 09:40:34 AM
    • Adaro: The client is in Download section at Homepage
      August 15, 2017, 01:09:20 AM
    • FaTe_Of_GoDs: where do i get the client?????????????
      August 14, 2017, 05:23:14 PM
    • stCky: can anyone help me? I cant login to the shoutbox
      August 13, 2017, 05:45:15 PM
    • drubrkletern: appeal denied
      August 13, 2017, 02:35:27 PM
    • King_Trout:[link]
      August 13, 2017, 11:17:12 AM
    • Cole1497: no sorry
      August 13, 2017, 10:27:14 AM

    Author Topic: 317 login protocol  (Read 671 times)

    0 Members and 1 Guest are viewing this topic.

    OfflineJoea

    • Member
    • **
    • Posts: 33
    • Thanks: +0/-0
      • View Profile
    317 login protocol
    « on: March 20, 2017, 03:50:11 AM »
    Hey. I'm just looking for some insight on my code so far for a 317 server.
    Code: [Select]
    public class NIOServer {
        static Random rand = new Random();
        static final int port = 43594;
        static long serverSessionKey = rand.nextLong();
        static int userId;
        static String username = "";
        static String password = "";
        static long clientSessionKey;
        static byte connectStatus;
        static byte size;
        static byte clientVersion;
        static int[] crcValues = {0, 0, 0, 0, 0, 0, 0, 0, 0};
        static byte playerStatus;
        static byte flagged;
       
        public static void main(String[] args) throws IOException {
                ServerSocket server = new ServerSocket(port);
                Socket client = server.accept();
                DataInputStream inputStream = new DataInputStream(client.getInputStream());
                DataOutputStream outputStream = new DataOutputStream(client.getOutputStream());
                //Stage 1: Client -> server
                System.out.println(inputStream.readUnsignedByte());
                System.out.println(inputStream.readUnsignedByte());
               
                //Stage 2: Server -> client
                outputStream.writeByte(0);// 8 ignored bytes
                outputStream.writeByte(0);
                outputStream.writeByte(0);
                outputStream.writeByte(0);
                outputStream.writeByte(0);
                outputStream.writeByte(0);
                outputStream.writeByte(0);
                outputStream.writeByte(0);
                outputStream.writeByte(0); //status code. 0 starts login protocol
                outputStream.writeLong(serverSessionKey);
               
                //stage 3: client -> server
               
                connectStatus = inputStream.readByte();
                size = inputStream.readByte();
                System.out.println(inputStream.read()); //255
                System.out.println(inputStream.readShort()); //317
                clientVersion = inputStream.readByte();
                crcValues[0] = inputStream.readInt();
                crcValues[1] = inputStream.readInt();
                crcValues[2] = inputStream.readInt();
                crcValues[3] = inputStream.readInt();
                crcValues[4] = inputStream.readInt();
                crcValues[5] = inputStream.readInt();
                crcValues[6] = inputStream.readInt();
                crcValues[7] = inputStream.readInt();
                crcValues[8] = inputStream.readInt();
                System.out.println(inputStream.read()); //supposed to be 10? comes up 0
                clientSessionKey = inputStream.readLong();
                serverSessionKey = inputStream.readLong();
                userId = inputStream.readInt();
                inputStream.read();//using readUTF() the code stops here
                inputStream.read();//^^^^^^^^^
               
                //stage 4: server -> client
                outputStream.writeByte(2); //response code. 2=successful login
                outputStream.writeByte(0); //player status
                outputStream.writeByte(0); //flagged 0=negative
                     {
           
                while (client.isBound()){
                    //do....
                }
            }
        }
    }

    what did i do wrong? what should i do different? ive put some comments in the code to things ive noticed. and dont say "use netty" because im doing this for the sole purpose of learning.
    « Last Edit: March 20, 2017, 03:54:55 AM by Joea »


    ?LUV ME!?


    OfflineiHeavenly

    • Member
    • **
    • Posts: 16
    • Thanks: +10/-10
      • View Profile
    Re: 317 login protocol
    « Reply #1 on: March 31, 2017, 02:19:05 PM »
    Maybe state which source you're using so people could check wether the variables are actually correct, besides that it looks decent for a beginner.


     

    Copyright © 2017 MoparScape. All rights reserved.
    Powered by SMFPacks SEO Pro Mod |
    SimplePortal 2.3.5 © 2008-2012, SimplePortal