Server Update:
Matchmaking V1.0 THIS VERSION INCLUDES THE FOLLOWING ITEMS: - Dynamic Fetching of indexed lobbies - Flushing and rebuilding of indexes on start.
This commit is contained in:
parent
9d7fd0e04f
commit
c744414f56
25
.idea/artifacts/MatchmakingBackend_jar.xml
generated
Normal file
25
.idea/artifacts/MatchmakingBackend_jar.xml
generated
Normal file
@ -0,0 +1,25 @@
|
||||
<component name="ArtifactManager">
|
||||
<artifact type="jar" build-on-make="true" name="MatchmakingBackend:jar">
|
||||
<output-path>$PROJECT_DIR$/out/artifacts/MatchmakingBackend_jar</output-path>
|
||||
<root id="archive" name="MatchmakingBackend.jar">
|
||||
<element id="module-output" name="MatchmakingBackend" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/slf4j/slf4j-api/1.7.32/slf4j-api-1.7.32.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/jsoup/jsoup/1.14.2/jsoup-1.14.2.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/javax/activation/activation/1.1/activation-1.1.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/com/googlecode/json-simple/json-simple/1.1.1/json-simple-1.1.1.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/apache/logging/log4j/log4j-api/2.17.0/log4j-api-2.17.0.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/controlsfx/controlsfx/11.1.1/controlsfx-11.1.1.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/net/lingala/zip4j/zip4j/2.6.1/zip4j-2.6.1.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/mongodb/bson/4.3.2/bson-4.3.2.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/junit/junit/4.10/junit-4.10.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/apache/logging/log4j/log4j-core/2.17.0/log4j-core-2.17.0.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/com/theokanning/openai-gpt3-java/api/0.4.0/api-0.4.0.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/mongodb/mongodb-driver-core/4.3.2/mongodb-driver-core-4.3.2.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/com/sun/mail/javax.mail/1.6.2/javax.mail-1.6.2.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/javax/mail/javax.mail-api/1.6.2/javax.mail-api-1.6.2.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/mongodb/mongodb-driver-sync/4.3.2/mongodb-driver-sync-4.3.2.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/com/jfoenix/jfoenix/8.0.10/jfoenix-8.0.10.jar" path-in-jar="/" />
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
3
src/main/java/META-INF/MANIFEST.MF
Normal file
3
src/main/java/META-INF/MANIFEST.MF
Normal file
@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Main-Class: com.jamesquinley.Main
|
||||
|
@ -1,22 +1,17 @@
|
||||
package com.jamesquinley.DelegationServices;
|
||||
import com.mongodb.BasicDBObject;
|
||||
import com.mongodb.ConnectionString;
|
||||
import com.mongodb.MongoClientSettings;
|
||||
import com.mongodb.MongoCommandException;
|
||||
import com.mongodb.*;
|
||||
import com.mongodb.client.MongoClient;
|
||||
import com.mongodb.client.MongoClients;
|
||||
import com.mongodb.client.MongoCollection;
|
||||
import com.mongodb.client.MongoDatabase;
|
||||
import org.bson.Document;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.print.Doc;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.mongodb.client.model.Filters.eq;
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
@ -32,7 +27,7 @@ public class delegationServices {
|
||||
static Document Lrequest = null;
|
||||
public static void connectionInit() {
|
||||
|
||||
scReadconnectionString = new ConnectionString("mongodb+srv://serverClient:x2sJ8Qu0VVMifNLX@accountdelegation.n06hb.mongodb.net/DelegationRequest?retryWrites=true&w=majority");
|
||||
scReadconnectionString = new ConnectionString("mongodb+srv://edgenetworknode:yUiWfJBYCGwdRayj@matchnethop.hgxv0xd.mongodb.net/?retryWrites=true&w=majority");
|
||||
//connects to database that production clients can use
|
||||
System.out.println("This is a production server build (and will only work on that type)");
|
||||
scReadsettings = MongoClientSettings.builder()
|
||||
@ -42,14 +37,12 @@ public class delegationServices {
|
||||
.readTimeout(6, SECONDS))
|
||||
.build();
|
||||
dClient = MongoClients.create(scReadsettings);
|
||||
dClientDatabase = dClient.getDatabase("DelegationRequest");
|
||||
dCollection = dClientDatabase.getCollection("accountRequest");
|
||||
RGFilterDB = dClient.getDatabase("rgcon");
|
||||
RGFilter = RGFilterDB.getCollection("blocked");
|
||||
|
||||
dClientDatabase = dClient.getDatabase("edgecomm");
|
||||
dCollection = dClientDatabase.getCollection("nettranslate");
|
||||
}
|
||||
static ConnectionString AccountCon = new ConnectionString("mongodb://accountserver:x2sJ8Qu0VVMifNLX@192.168.1.5:27017/account?retryWrites=true&w=majority");
|
||||
static ConnectionString AccountCon = new ConnectionString("mongodb://matchmakingbackend:erhijew983ruefeyf@192.168.1.5:27017/gameservices?retryWrites=true&w=majority");
|
||||
//mongodb://localhost:27017
|
||||
//erhijew983ruefeyf
|
||||
//mongodb://accountserver:x2sJ8Qu0VVMifNLX@192.168.1.5:27017/account?retryWrites=true&w=majority
|
||||
static MongoClientSettings AccountSettings = MongoClientSettings.builder()
|
||||
.applyConnectionString(AccountCon)
|
||||
@ -58,49 +51,137 @@ public class delegationServices {
|
||||
.readTimeout(6, SECONDS))
|
||||
.build();
|
||||
static MongoClient accountGetClient = MongoClients.create(AccountSettings);
|
||||
static MongoDatabase accountDatabase = accountGetClient.getDatabase("account");
|
||||
static MongoCollection<Document> accountS = accountDatabase.getCollection("UserPass");
|
||||
static MongoDatabase database = accountGetClient.getDatabase("guilds");
|
||||
|
||||
static MongoCollection<Document> scCollection = database.getCollection("userCredits");
|
||||
static MongoDatabase gameServices = accountGetClient.getDatabase("gameservices");
|
||||
static MongoCollection<Document> lobbyIndex = gameServices.getCollection("matchmaking");
|
||||
static MongoDatabase database = accountGetClient.getDatabase("service");
|
||||
static MongoCollection<Document> servicesStatus = database.getCollection("config");
|
||||
static int RequestR;
|
||||
//still need to config
|
||||
|
||||
/*
|
||||
Request (Simple) Index
|
||||
|
||||
1 - Get all active lobbies
|
||||
2 - Return All lobbies request
|
||||
3 - Submit Lobby for posting
|
||||
4 - Return posting and lobby key
|
||||
5 - Submit Lobby de-listing request
|
||||
6 - Return de-lisitng result (return status is deleted:true;false)
|
||||
*/
|
||||
|
||||
public static void delegationProcesser() {
|
||||
Document Filter;
|
||||
Object ClientID = null;
|
||||
String RG = (String) Lrequest.get("filter");
|
||||
Filter = RGFilter.find(eq("rgkey", "UAROCKS")).first();
|
||||
try {
|
||||
ClientID = Lrequest.get("_id");
|
||||
} catch (Exception exrp) {
|
||||
System.out.println("This request has opted out of CID.");
|
||||
}
|
||||
int request = (int) Lrequest.get("type");
|
||||
if (request == 1 || request == 3) {
|
||||
if (request ==1 ) {
|
||||
List<String> lobbyNameList = new ArrayList<>();
|
||||
List<String> lobbyIPList = new ArrayList<>();
|
||||
List<String> lobbyKeyList = new ArrayList<>();
|
||||
BasicDBObject requestModifier = new BasicDBObject();
|
||||
requestModifier.append("_id", ClientID);
|
||||
BasicDBObject updateQuery = new BasicDBObject();
|
||||
BasicDBObject nameUpdate = new BasicDBObject();
|
||||
BasicDBObject ipUpdate = new BasicDBObject();
|
||||
BasicDBObject statusUpdate = new BasicDBObject();
|
||||
BasicDBObject lobbyNum = new BasicDBObject();
|
||||
|
||||
public static void Purge() {
|
||||
|
||||
Document index = new Document();
|
||||
index = lobbyIndex.find(eq("indexref", "ocs_matchmakingidx")).first();
|
||||
lobbyNameList = (List<String>) index.get("LobbyName");
|
||||
lobbyIPList = (List<String>) index.get("LobbyIP");
|
||||
//lobbyKeyList = (List<String>) index.get("LobbyPrivateKey");
|
||||
System.out.println(lobbyNameList);
|
||||
System.out.println(lobbyIPList);
|
||||
if (lobbyNameList.stream().count() -1 ==0) {
|
||||
nameUpdate.append("$set",
|
||||
new BasicDBObject().append("lobbies", "No lobbies are available..."));
|
||||
updateQuery.append("$set",
|
||||
new BasicDBObject().append("type", 2));
|
||||
lobbyNum.append("$set",
|
||||
new BasicDBObject().append("LobbyCount", 0));
|
||||
statusUpdate.append("$set",
|
||||
new BasicDBObject().append("status", true));
|
||||
dCollection.updateOne(requestModifier, updateQuery);
|
||||
dCollection.updateOne(requestModifier,nameUpdate);
|
||||
dCollection.updateOne(requestModifier,lobbyNum);
|
||||
dCollection.updateOne(requestModifier, statusUpdate);
|
||||
DeleteTargetRequestByID(ClientID);
|
||||
} else {
|
||||
updateQuery.append("$set",
|
||||
new BasicDBObject().append("type", 2));
|
||||
nameUpdate.append("$set",
|
||||
new BasicDBObject().append("lobbies", lobbyNameList));
|
||||
ipUpdate.append("$set",
|
||||
new BasicDBObject().append("ip", lobbyIPList));
|
||||
lobbyNum.append("$set",
|
||||
new BasicDBObject().append("LobbyCount", (int) lobbyNameList.stream().count() -1));
|
||||
statusUpdate.append("$set",
|
||||
new BasicDBObject().append("status", true));
|
||||
dCollection.updateOne(requestModifier, updateQuery);
|
||||
dCollection.updateOne(requestModifier, nameUpdate);
|
||||
dCollection.updateOne(requestModifier, ipUpdate);
|
||||
dCollection.updateOne(requestModifier,lobbyNum);
|
||||
dCollection.updateOne(requestModifier, statusUpdate);
|
||||
DeleteTargetRequestByID(ClientID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void DeleteTargetRequestByID (Object ID)
|
||||
{
|
||||
final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
|
||||
final Runnable runnable = new Runnable() {
|
||||
int countdownStarter = 5;
|
||||
public void run() {
|
||||
countdownStarter--;
|
||||
if (countdownStarter <= 0) {
|
||||
countdownStarter = 5;
|
||||
BasicDBObject searchQuery = new BasicDBObject();
|
||||
searchQuery.append("_id", ID);
|
||||
dCollection.deleteMany(searchQuery);
|
||||
System.out.println("Flushed a targeted request (CID) from the server");
|
||||
scheduler.shutdown();
|
||||
}
|
||||
}
|
||||
};
|
||||
scheduler.scheduleAtFixedRate(runnable, 0, 1, TimeUnit.SECONDS);
|
||||
}
|
||||
public static void init() {
|
||||
BasicDBObject searchQueryT = new BasicDBObject();
|
||||
BasicDBObject searchQueryF = new BasicDBObject();
|
||||
BasicDBObject LobbyIndex = new BasicDBObject();
|
||||
searchQueryT.append("status", true);
|
||||
searchQueryF.append("status", false);
|
||||
LobbyIndex.append("indexref", "ocs_matchmakingidx");
|
||||
dCollection.deleteMany(searchQueryT);
|
||||
dCollection.deleteMany(searchQueryF);
|
||||
System.out.println("Flushed Server");
|
||||
}
|
||||
|
||||
public static void TargetDelete(Object ID) {
|
||||
BasicDBObject searchQuery = new BasicDBObject();
|
||||
searchQuery.append("_id", ID);
|
||||
dCollection.deleteMany(searchQuery);
|
||||
System.out.println("Flushed a targeted request (CID) from the server");
|
||||
System.out.println("Flushed NetJump Server");
|
||||
lobbyIndex.deleteMany(LobbyIndex);
|
||||
System.out.println("Flushed Matchmaking Index Server");
|
||||
System.out.println("Creating Matchmaking Storage Index...");
|
||||
Document lobbyIndexTemplate = new Document();
|
||||
List<String> lobbyNameList = new ArrayList<>();
|
||||
List<String> lobbyIPList = new ArrayList<>();
|
||||
List<String> lobbyKeyList = new ArrayList<>();
|
||||
lobbyNameList.add("startatone");
|
||||
lobbyIPList.add("startatone");
|
||||
lobbyKeyList.add("startatone");
|
||||
lobbyIndexTemplate.append("LobbyName",lobbyNameList);
|
||||
lobbyIndexTemplate.append("LobbyIP", lobbyIPList);
|
||||
lobbyIndexTemplate.append("LobbyPrivateKey",lobbyKeyList);
|
||||
lobbyIndexTemplate.append("indexref", "ocs_matchmakingidx");
|
||||
lobbyIndex.insertOne(lobbyIndexTemplate);
|
||||
|
||||
|
||||
}
|
||||
public static void TargetDeleteByID(Object ID) {
|
||||
BasicDBObject searchQuery = new BasicDBObject();
|
||||
searchQuery.append("_id", ID);
|
||||
dCollection.deleteMany(searchQuery);
|
||||
System.out.println("Flushed a targeted request (CID) from the server");
|
||||
|
||||
|
||||
}
|
||||
public static void userAuthetication() {
|
||||
public static void matchmakingService() {
|
||||
Lrequest = dCollection.find(eq("status", false)).first();
|
||||
if (!(Lrequest == null)) {
|
||||
delegationProcesser();
|
||||
|
@ -1,14 +1,16 @@
|
||||
package com.jamesquinley;
|
||||
|
||||
import static com.jamesquinley.DelegationServices.delegationServices.init;
|
||||
|
||||
/**
|
||||
I/O and lobby management backend for new sandbox multiplayer game, go team (Marci and I!)
|
||||
*/
|
||||
public class Main {
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
com.jamesquinley.DelegationServices.delegationServices.connectionInit();
|
||||
com.jamesquinley.DelegationServices.delegationServices.Purge();
|
||||
System.out.println("We're starting the login delegation server, please wait one moment while we check a few things.");
|
||||
System.out.println("We've started everything, requests are now being served");
|
||||
System.out.println("Connected to NetJump server and Matchmaking Storage Server");
|
||||
init();
|
||||
System.out.println("An index has been initialized, matchmaking is now enabled.");
|
||||
while (true) {
|
||||
isolatedTrigger();
|
||||
Thread.sleep(500);
|
||||
@ -17,9 +19,9 @@ public class Main {
|
||||
|
||||
static void isolatedTrigger() {
|
||||
try {
|
||||
com.jamesquinley.DelegationServices.delegationServices.userAuthetication();
|
||||
com.jamesquinley.DelegationServices.delegationServices.matchmakingService();
|
||||
} catch (Exception e) {
|
||||
System.out.println("We ran into an issue, this is a known issue and will be fixed once I can figure it out. " + e.getCause());
|
||||
System.out.println("Something went wrong, DEBUG: " + e);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package com.jamesquinley.testing;
|
||||
|
||||
public class splitFNet {
|
||||
public static void splitNet ()
|
||||
{
|
||||
String s1 = "['This', 'Is', 'Split', 'Get', 'It?']";
|
||||
|
||||
String[] array = s1.split(",");
|
||||
for(int i=0;i<array.length;i++)
|
||||
{
|
||||
// System.out.println(array[i]);
|
||||
//testing for larger fNetLists
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user