-
Notifications
You must be signed in to change notification settings - Fork 0
Java Edition
In maven you must add the following repository:
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
I in dependencies:
<dependency>
<groupId>com.github.Creadores-Program</groupId>
<artifactId>ServerWebGamePost</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.creadoresprogram</groupId>
<artifactId>ServerWebGamePost</artifactId>
<version>1.1.1</version>
</dependency>
First you need to extend the org.CreadoresProgram.ServerWebGamePost.server.ProcessDatapackServer class
And to process the datapackets that the client sends you must implement Override to the processDatapack function
Something like that:
@Override
public void processDatapack(JSONObject datapack){
//code...
//JSONObject= com.alibaba.fastjson2.JSONObject
//this.server = org.CreadoresProgram.ServerWebGamePost.server.ServerWebGamePostServer instance
}
Simply in the org.CreadoresProgram.ServerWebGamePost.server.ServerWebGamePostServer class Execute the sendDataPacket function
Something like that:
//ServerWebGamePostServer = server
server.sendDataPacket(identifier, json); //identifier you must obtain from the datapacket that the client gives in its datapacket (it is a String) json Is com.alibaba.fastjson2.JSONObject
You must create a new org.CreadoresProgram.ServerWebGamePost.server.ServerWebGamePostServer instance
ServerWebGamePostServer server = new ServerWebGamePostServer(port, imgSrc, procecerDatapacks);
// port = int(Here you must specify the port where the server opens), imgSrc = String (Directory in string of the server icon type image can be null), procecerDatapacks = ProcessDatapackServer (Datapacket handling instance class)
If you want to implement HTTPS just use the Spark java API
Get the spark service:
//ServerWebGamePostServer = server
server.getSparkServer();
just run the stop function in the Server class
First you need to extend the org.CreadoresProgram.ServerWebGamePost.client.ProcessDatapackClient class
And to process the datapackets that the server sends you must implement Override to the processDatapack function
Something like that:
@Override
public void processDatapack(JSONObject datapack){
//code...
//JSONObject= com.alibaba.fastjson2.JSONObject
//this.server = org.CreadoresProgram.ServerWebGamePost.client.ServerWebGamePostClient instance
}
Simply in the org.CreadoresProgram.ServerWebGamePost.client.ServerWebGamePostClient class Execute the sendDataPacket function
Something like that:
//ServerWebGamePostClient = client
client.sendDataPacket(json); //Remember to add the identifier key to the json (it is a String) json Is com.alibaba.fastjson2.JSONObject
You must create a new org.CreadoresProgram.ServerWebGamePost.client.ServerWebGamePostClient instance
ServerWebGamePostClient client = new ServerWebGamePostClient(domain, port, isHttps);
// domain = String(server domain or ip), port = int(Here you must specify the port where the server), isHttps = boolean(Find out if the server has HTTPS encryption or not)
ProcessDatapackClient procecerDatapacks = new ProcessDatapackClient(client);//your class extends
client.setProcessDatapacks(procecerDatapacks);
//procecerDatapacks = ProcessDatapackClient (Datapacket handling instance class)