Thread: Player Connection/website

Results 1 to 6 of 6
  1. #1 Player Connection/website 
    Registered Member Fagex.'s Avatar
    Join Date
    May 2010
    Posts
    63
    Thanks given
    0
    Thanks received
    0
    Rep Power
    12
    I am using DeltaClean 2.0

    (It's to fuck around with!) but I cannot find where in God's green earth to add the Code.

    I guessed in Server.java, at the beginning. This is my error:
    Code:
    Compiling Server
    .\com\rs2\Server.java:65: cannot find symbol
    symbol  : variable connection
    location: class com.rs2.Server
                                            DataInputStream input = new DataInputStr
    eam(connection.getInputStream());//Gets the input stream from the socket(Allows
    the server to read)
    
        ^
    .\com\rs2\Server.java:66: cannot find symbol
    symbol  : variable connection
    location: class com.rs2.Server
                                            DataOutputStream output = new DataOutput
    Stream(connection.getOutputStream());//Gets the output stream for the socket(All
    ows the server to write)
    
           ^
    .\com\rs2\Server.java:69: cannot find symbol
    symbol  : variable connection
    location: class com.rs2.Server
                    ServerEngine.addConnection(connection);//Handles client connecti
    on. REPLACE WITH HOWEVER YOUR SERVER HANDLES LOGINS.
                                               ^
    .\com\rs2\Server.java:69: cannot find symbol
    symbol  : variable ServerEngine
    location: class com.rs2.Server
                    ServerEngine.addConnection(connection);//Handles client connecti
    on. REPLACE WITH HOWEVER YOUR SERVER HANDLES LOGINS.
                    ^
    .\com\rs2\Server.java:71: cannot find symbol
    symbol  : method getPlayersOnline()
    location: class com.rs2.GameEngine
                    output.writeUTF(String.valueOf(GameEngine.getPlayersOnline()));/
    /UTF because that's the way php reads and writes data.
                                                             ^
    .\com\rs2\Server.java:74: cannot find symbol
    symbol  : variable connection
    location: class com.rs2.Server
                    connection.close();
                    ^
    .\com\rs2\Server.java:78: cannot find symbol
    symbol  : variable connection
    location: class com.rs2.Server
                    connection.close();
                    ^
    7 errors
    Compiling completed.
    Press any key to continue . . .
    THIS IS THE TUTORIAL ON DOING IT THAT I USED:
    Okay, now a while ago, i came to the realization that there had to have been an easier way to get the players online, without creating an ambiguous structure in MySQL or an extraneous file on some ftp server somewhere. So I thought, why not pull the the amount of players directly from the server? So I did just that.

    First, you need to add some php to your webcode. Now, go into the page you'd like to display the number of characters online(commonly index.php), and add this php code:
    Code:
    <?php
            $host = "yourserversiphere";#The IP of your 
            $port = 43594;#The Port your server listens to
            $socket = fsockopen($host, $port);#Connect to the server
            fputs($socket, pack("i", 15));#Write byte 15
            $players = substr(fgets($socket, 128), 2);#Read the data sent by the server
            fclose($socket);#Close the connection
            echo "There are " . $players . " players online";
    ?>
    Next, in the class where you handle socket connections(Probably somewhere along the lines of SocketListener, or LoginHandler, or ConnectionManger), you should see something that looks like this:
    Code: [Select]
    Socket connection = serverSocket.accept();

    Under that, add this:
    Code:
    DataInputStream input = new DataInputStream(connection.getInputStream());//Gets the input stream from the socket(Allows the server to read)
    DataOutputStream output = new DataOutputStream(connection.getOutputStream());//Gets the output stream for the socket(Allows the server to write)
    int connectionType = input.readByte();//Type of connection
    And don't forget to import java.io.*;

    Now, most clients send byte 14 first, over all other data sent. So we'll use this to our advantage. Next add this right below:
    Code:
            if(connectionType == 14) {
                    ServerEngine.addConnection(connection);//Handles client connection. REPLACE WITH HOWEVER YOUR SERVER HANDLES LOGINS.
            } else if(connectionType == 15) {//Handle request from webpage
                    output.writeUTF(String.valueOf(GameEngine.getPlayersOnline()));//UTF because that's the way php reads and writes data.
                    input.close();
                    output.close();
                    connection.close();
            } else {//Invalid connection
                    input.close();
                    output.close();
                    connection.close();
            }
    Now, whenever anyone loads the page, it requests the data from the server, and the web page reads that data and displays it. Hope you enjoyed it. I know that there may be some slight discrepancies in the tutorial, and i will fix it tomorrow. I'm going on 6 days without sleep at the moment.
    Reply With Quote  
     

  2. #2  
    Super Donator


    Join Date
    Sep 2008
    Age
    30
    Posts
    1,894
    Thanks given
    677
    Thanks received
    776
    Rep Power
    456
    Code:
    .\com\rs2\Server.java:69: cannot find symbol
    symbol  : variable connection
    Is imports bro
    Reply With Quote  
     

  3. #3  
    Registered Member Fagex.'s Avatar
    Join Date
    May 2010
    Posts
    63
    Thanks given
    0
    Thanks received
    0
    Rep Power
    12
    Imports too what?
    Reply With Quote  
     

  4. #4  
    Registered Member Fagex.'s Avatar
    Join Date
    May 2010
    Posts
    63
    Thanks given
    0
    Thanks received
    0
    Rep Power
    12
    Anyone at all?
    Reply With Quote  
     

  5. #5  
    Banned

    Join Date
    Dec 2009
    Posts
    833
    Thanks given
    8
    Thanks received
    8
    Rep Power
    0
    ServerEngine.

    that is stating that its a file.
    If you have the file ServerEngine import it.
    Reply With Quote  
     

  6. #6  
    Registered Member Fagex.'s Avatar
    Join Date
    May 2010
    Posts
    63
    Thanks given
    0
    Thanks received
    0
    Rep Power
    12
    I don't have it. I am using DeltaCleaned. What would that file be in DC?
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •