mirror of
https://github.com/maierfelix/POGOserver.git
synced 2026-07-10 14:36:41 -05:00
Update
- Splitted database stages - Refactored config - Added mysql config - Correct map object pokemon id - Added updated discord link
This commit is contained in:
parent
9f9e54b7c5
commit
54473ef8d7
|
|
@ -10,7 +10,7 @@ ______ _____ _____ _____
|
|||
<a href="#">
|
||||
<img src="https://img.shields.io/badge/Pokemon%20GO-0.33.0-blue.svg?style=flat-square" />
|
||||
</a>
|
||||
<a href="https://discord.gg/M3bdv">
|
||||
<a href="https://discord.gg/gu8ZUJp">
|
||||
<img src="https://img.shields.io/badge/Discord-Join%20Chat%20%E2%86%92-738bd7.svg?style=flat-square" />
|
||||
</a>
|
||||
|
||||
|
|
|
|||
24
cfg.js
24
cfg.js
|
|
@ -1,3 +1,7 @@
|
|||
export const ASSET_DIGEST_PATH = "asset_digest";
|
||||
|
||||
export const MINIMUM_CLIENT_VERSION = "0.33.0";
|
||||
|
||||
export const SERVER_PORT = 3000;
|
||||
export const SERVER_HOST_IP = "127.0.0.1";
|
||||
export const SERVER_GAME_MODE = 0;
|
||||
|
|
@ -10,18 +14,26 @@ export const SERVER_LOG_REQUESTS = true;
|
|||
|
||||
export const SERVER_DEFAULT_CONSOLE_COLOR = 32;
|
||||
|
||||
export const ASSET_DIGEST_PATH = "asset_digest";
|
||||
|
||||
export const MINIMUM_CLIENT_VERSION = "0.33.0";
|
||||
// Either mongo or mysql
|
||||
// Dont use mysql right now
|
||||
export const SERVER_USE_DATABASE = "MONGO";
|
||||
|
||||
// MONGODB
|
||||
export const SERVER_MONGO_PORT = 27017;
|
||||
export const SERVER_MONGO_HOST_IP = "localhost";
|
||||
export const SERVER_MONGO_HOST_IP = "127.0.0.1";
|
||||
export const SERVER_MONGO_DB_NAME = "pokemongo";
|
||||
export const SERVER_MONGO_COLLECTION_USERS = "users";
|
||||
export const SERVER_MONGO_URL = `mongodb://${SERVER_MONGO_HOST_IP}:${SERVER_MONGO_PORT}/${SERVER_MONGO_DB_NAME}`;
|
||||
|
||||
export const SERVER_GMAPS_API_KEY = "AIzaSyDF9rkP8lhcddBtvH9gVFzjnNo13WtmJIM";
|
||||
// MYSQL
|
||||
export const SERVER_MYSQL_PORT = 3306;
|
||||
export const SERVER_MYSQL_HOST_IP = "127.0.0.1";
|
||||
export const SERVER_MYSQL_DB_NAME = "pogosql";
|
||||
export const SERVER_MYSQL_USERNAME = "USERNAME";
|
||||
export const SERVER_MYSQL_PASSWORD = "PASSWORD";
|
||||
|
||||
// account used for pogo-asset-downloader lib
|
||||
export const SERVER_POGO_CLIENT_USERNAME = "USERNAME";
|
||||
export const SERVER_POGO_CLIENT_PASSWORD = "PASSWORD";
|
||||
export const SERVER_POGO_CLIENT_PASSWORD = "PASSWORD";
|
||||
|
||||
export const SERVER_GMAPS_API_KEY = "AIzaSyDF9rkP8lhcddBtvH9gVFzjnNo13WtmJIM";
|
||||
|
|
@ -20,6 +20,7 @@
|
|||
"nodemon": "^1.7.1",
|
||||
"protobufjs": "^5.0.1",
|
||||
"mongodb": "^2.2.5",
|
||||
"mysql": "^2.11.1",
|
||||
"jwt-decode": "^2.1.0",
|
||||
"long": "^3.2.0",
|
||||
"pogo-asset-downloader": "^0.1.0",
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
import mongodb from "mongodb";
|
||||
|
||||
import * as CFG from "../cfg";
|
||||
import * as CFG from "../../cfg";
|
||||
|
||||
export function setupMongo() {
|
||||
|
||||
return new Promise((resolve) => {
|
||||
mongodb.MongoClient.connect(CFG.SERVER_MONGO_URL, (error, db) => {
|
||||
if (error) {
|
||||
this.print("Unable to connect to database", 31);
|
||||
this.print(error, 31);
|
||||
} else {
|
||||
this.db.instance = db;
|
||||
this.loadCollection(CFG.SERVER_MONGO_COLLECTION_USERS).then(() => {
|
||||
26
src/db/mysql.js
Normal file
26
src/db/mysql.js
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import mysql from "mysql";
|
||||
|
||||
import * as CFG from "../../cfg";
|
||||
|
||||
export function setupMySQL() {
|
||||
|
||||
let connection = mysql.createConnection({
|
||||
host : CFG.SERVER_MYSQL_HOST_IP,
|
||||
port : CFG.SERVER_MYSQL_PORT,
|
||||
database : CFG.SERVER_MYSQL_DB_NAME,
|
||||
user : CFG.SERVER_MYSQL_USERNAME,
|
||||
password : CFG.SERVER_MYSQL_PASSWORD
|
||||
});
|
||||
|
||||
return new Promise((resolve) => {
|
||||
connection.connect((error) => {
|
||||
if (error) {
|
||||
this.print(error, 31);
|
||||
return void 0;
|
||||
}
|
||||
this.db.instance = connection;
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -16,7 +16,8 @@ import * as _player from "./player";
|
|||
import * as _request from "./request";
|
||||
import * as _response from "./response";
|
||||
import * as _process from "./process";
|
||||
import * as _database from "./database";
|
||||
import * as _mongo from "./db/mongo";
|
||||
import * as _mysql from "./db/mysql";
|
||||
|
||||
const greetMessage = fs.readFileSync(".greet", "utf8");
|
||||
|
||||
|
|
@ -153,7 +154,8 @@ inherit(GameServer, _player);
|
|||
inherit(GameServer, _request);
|
||||
inherit(GameServer, _response);
|
||||
inherit(GameServer, _process);
|
||||
inherit(GameServer, _database);
|
||||
inherit(GameServer, _mongo);
|
||||
inherit(GameServer, _mysql);
|
||||
|
||||
let server = new GameServer();
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ export default function GetMapObjects(request) {
|
|||
longitude: -96.58502161502839,
|
||||
spawn_point_id: "87bdd289c69",
|
||||
pokemon_data: new proto.Data.PokemonData({
|
||||
pokemon_id: 19,
|
||||
pokemon_id: 16,
|
||||
cp: 277,
|
||||
stamina: 41,
|
||||
stamina_max: 41,
|
||||
|
|
|
|||
26
src/setup.js
26
src/setup.js
|
|
@ -8,7 +8,7 @@ export function setup() {
|
|||
|
||||
this.createAssetDownloadSession().then(() => {
|
||||
this.print("Created asset download session");
|
||||
this.setupMongo().then(() => {
|
||||
this.setupDatabaseConnection().then(() => {
|
||||
|
||||
this.print("Database connection established");
|
||||
|
||||
|
|
@ -26,4 +26,28 @@ export function setup() {
|
|||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
export function setupDatabaseConnection() {
|
||||
|
||||
return new Promise((resolve) => {
|
||||
|
||||
let name = String(CFG.SERVER_USE_DATABASE).toUpperCase();
|
||||
|
||||
switch (name) {
|
||||
case "MONGO":
|
||||
case "MONGODB":
|
||||
this.setupMongo().then(resolve);
|
||||
break;
|
||||
case "MYSQL":
|
||||
this.setupMySQL().then(resolve);
|
||||
break;
|
||||
default:
|
||||
this.print("Invalid database connection type!", 31);
|
||||
return void 0;
|
||||
break;
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user