The client and server how do they send packet?

Started by 2b2ttianxiu, Jan 02, 2023, 12:16 PM

Previous topic - Next topic

2b2ttianxiu

The client and server how do they send packet?
I only getted server info.

PSL

Let me show you a piece of code and hope this helps you.
//The server sends hello to the client
local stream=Stream();
stream.StartWrite();
stream.WriteString("hello");
stream.SendStream(player);

//The client accepts it and prints it
function Server::ServerData( stream )
{
     local string=stream.ReadString();
     Console.Print(string);
}

2b2ttianxiu

Quote from: PSL on Jan 02, 2023, 01:05 PMLet me show you a piece of code and hope this helps you.
//The server sends hello to the client
local stream=Stream();
stream.StartWrite();
stream.WriteString("hello");
stream.SendStream(player);

//The client accepts it and prints it
function Server::ServerData( stream )
{
     local string=stream.ReadString();
     Console.Print(string);
}
I want to send packet on udp protocol. So you just a simple server to client stream.

habi

Quote from: 2b2ttianxiu on Jan 02, 2023, 12:16 PMI only getted server info.
What do you mean?

client sends one packet  for each item : Getting-server-info, ping, player-list.
For each packet, server responds with reply packet.
See
http://wiki.thijn.ovh/index.php?title=Query_Mechanism

2b2ttianxiu

Quote from: habi on Jan 02, 2023, 04:14 PM
Quote from: 2b2ttianxiu on Jan 02, 2023, 12:16 PMI only getted server info.
What do you mean?

client sends one packet  for each item : Getting-server-info, ping, player-list.
For each packet, server responds with reply packet.
See
http://wiki.thijn.ovh/index.php?title=Query_Mechanism
I want to make a proxy server.
I don't know how send message to client. not on server send message

habi

If you are making a proxy server, just forward whatever UDP datagrams client sends to server.

Similarly route all server packets to client. Ah! i see.

https://imgur.io/Mag0djm?r

No communication between clients.

Additional info: It uses Raknet. One Raknet server and many clients.

2b2ttianxiu

Quote from: habi on Jan 13, 2023, 02:36 PMIf you are making a proxy server, just forward whatever UDP datagrams client sends to server.

Similarly route all server packets to client. Ah! i see.

https://imgur.io/Mag0djm?r

No communication between clients.

Additional info: It uses Raknet. One Raknet server and many clients.

I did, but I wasnt get client ip, i use Python made proxy server, only get proxy server ip

2b2ttianxiu

Quote from: habi on Jan 13, 2023, 02:36 PMIf you are making a proxy server, just forward whatever UDP datagrams client sends to server.

Similarly route all server packets to client. Ah! i see.

https://imgur.io/Mag0djm?r

No communication between clients.

Additional info: It uses Raknet. One Raknet server and many clients.

What are these? It's not a source website

habi

#8
You wanted to setup an updater URL of your own.

1. Add the address: http://yourwebsitepath.com ( and not http://yourwebsitepath.com/ ) to VCMP Browser->Tools->Settings->Updater URL

2. Now in your server where you are going to create 'php scripts', create two folders -
1. download 2. check
such that
http://yourwebsitepath.com/download/ and http://yourwebsitepath.com/check/ is accessible.

3. download/index.php
<?php
$jsonobj 
$_POST['json'];

$obj json_decode($jsonobj);

if (
property_exists($obj'version'))
{
if(
$obj->version=="04rel006")
{
$attachment_location $_SERVER["DOCUMENT_ROOT"] . "/download/62A35348.7z";
        if (
file_exists($attachment_location)) {

            
header($_SERVER["SERVER_PROTOCOL"] . " 200 OK");
            
header("Content-Description: File Transfer");
            
header("Cache-Control:  must-revalidate, post-check=0, pre-check=0"); 
            
header("Content-Type: application/octet-stream");
            
header("Content-Transfer-Encoding: Binary");
            
header("Expires: 0");
            
header("Content-Length:".filesize($attachment_location));
            
header("Connection: keep-alive");
            
header("Content-Disposition: attachment; filename=62A35348.7z");
            
readfile($attachment_location);
            die();
        } else {
            die(
"Error: File not found.");
        }
}
}
else echo 
"version not specified";
?>


Now you need to have file download/62A35348.7z
The name does not matter, but it should be same everywhere. You can make this file by yourself by creating a 7zip archive from 04rel006 folder of AppData/Local/Vice City Multiplayer. Thus contents of 7z and 04rel006 folder are same:images, version.txt,sa_vehicle.txd,...

4. check/index.php
<?php
        header
($_SERVER["SERVER_PROTOCOL"] . " 200 OK");
        
header("Content-Type: text/html");
        
header("Connection: close");
        die();
?>

Note: I don't know the u04.vc-mp.org update( 'Check for updates') is not working. However when you double-click any server, it downloads. So to avoid error message(when checking for update..)we are building this(check/index.php)

Try it!

2b2ttianxiu

Quote from: habi on Jan 16, 2023, 09:47 AMYou wanted to setup an updater URL of your own.

1. Add the address: http://yourwebsitepath.com ( and not http://yourwebsitepath.com/ ) to VCMP Browser->Tools->Settings->Updater URL

2. Now in your server where you are going to create 'php scripts', create two folders -
1. download 2. check
such that
http://yourwebsitepath.com/download/ and http://yourwebsitepath.com/check/ is accessible.

3. download/index.php
<?php
$jsonobj 
$_POST['json'];

$obj json_decode($jsonobj);

if (
property_exists($obj'version'))
{
if(
$obj->version=="04rel006")
{
$attachment_location $_SERVER["DOCUMENT_ROOT"] . "/download/62A35348.7z";
        if (
file_exists($attachment_location)) {

            
header($_SERVER["SERVER_PROTOCOL"] . " 200 OK");
            
header("Content-Description: File Transfer");
            
header("Cache-Control:  must-revalidate, post-check=0, pre-check=0"); 
            
header("Content-Type: application/octet-stream");
            
header("Content-Transfer-Encoding: Binary");
            
header("Expires: 0");
            
header("Content-Length:".filesize($attachment_location));
            
header("Connection: keep-alive");
            
header("Content-Disposition: attachment; filename=62A35348.7z");
            
readfile($attachment_location);
            die();
        } else {
            die(
"Error: File not found.");
        }
}
}
else echo 
"version not specified";
?>


Now you need to have file download/62A35348.7z
The name does not matter, but it should be same everywhere. You can make this file by yourself by creating a 7zip archive from 04rel006 folder of AppData/Local/Vice City Multiplayer. Thus contents of 7z and 04rel006 folder are same:images, version.txt,sa_vehicle.txd,...

4. check/index.php
<?php
        header
($_SERVER["SERVER_PROTOCOL"] . " 200 OK");
        
header("Content-Type: text/html");
        
header("Connection: close");
        die();
?>

Note: I don't know the u04.vc-mp.org update( 'Check for updates') is not working. However when you double-click any server, it downloads. So to avoid error message(when checking for update..)we are building this(check/index.php)

Try it!

Thanks. (How find it?)

2b2ttianxiu

Quote from: habi on Jan 16, 2023, 09:47 AMYou wanted to setup an updater URL of your own.

1. Add the address: http://yourwebsitepath.com ( and not http://yourwebsitepath.com/ ) to VCMP Browser->Tools->Settings->Updater URL

2. Now in your server where you are going to create 'php scripts', create two folders -
1. download 2. check
such that
http://yourwebsitepath.com/download/ and http://yourwebsitepath.com/check/ is accessible.

3. download/index.php
<?php
$jsonobj 
$_POST['json'];

$obj json_decode($jsonobj);

if (
property_exists($obj'version'))
{
if(
$obj->version=="04rel006")
{
$attachment_location $_SERVER["DOCUMENT_ROOT"] . "/download/62A35348.7z";
        if (
file_exists($attachment_location)) {

            
header($_SERVER["SERVER_PROTOCOL"] . " 200 OK");
            
header("Content-Description: File Transfer");
            
header("Cache-Control:  must-revalidate, post-check=0, pre-check=0"); 
            
header("Content-Type: application/octet-stream");
            
header("Content-Transfer-Encoding: Binary");
            
header("Expires: 0");
            
header("Content-Length:".filesize($attachment_location));
            
header("Connection: keep-alive");
            
header("Content-Disposition: attachment; filename=62A35348.7z");
            
readfile($attachment_location);
            die();
        } else {
            die(
"Error: File not found.");
        }
}
}
else echo 
"version not specified";
?>


Now you need to have file download/62A35348.7z
The name does not matter, but it should be same everywhere. You can make this file by yourself by creating a 7zip archive from 04rel006 folder of AppData/Local/Vice City Multiplayer. Thus contents of 7z and 04rel006 folder are same:images, version.txt,sa_vehicle.txd,...

4. check/index.php
<?php
        header
($_SERVER["SERVER_PROTOCOL"] . " 200 OK");
        
header("Content-Type: text/html");
        
header("Connection: close");
        die();
?>

Note: I don't know the u04.vc-mp.org update( 'Check for updates') is not working. However when you double-click any server, it downloads. So to avoid error message(when checking for update..)we are building this(check/index.php)

Try it!

ummm, This topic is talking about vc-mp protocol.