Re: RealityRP [RP][C#][PHP][R63]
Amg!!
Caching users!!
I'm fainting, get a doc!!!
Re: RealityRP [RP][C#][PHP][R63]
Quote:
Originally Posted by
tdid
caching users? You must be kidding me
Catching users? You think it's fake?
http://108.61.45.61/test.rar
Currently completed:
- Main style for all dialogues
- Connecting to database
- Saving database settings
Re: RealityRP [RP][C#][PHP][R63]
Can i have Screens? The Features and commands looks nice. Good luck!
Re: RealityRP [RP][C#][PHP][R63]
Quote:
Originally Posted by
Divide
Catching users? You think it's fake?
http://108.61.45.61/test.rar
Currently completed:
- Main style for all dialogues
- Connecting to database
- Saving database settings
This sounds like a ridiculous idea, are you caching everything in the users table or just specific things?
Lets say a user signs up, but the emulator has already cached the users so how would the new user log in? Would a member of staff have to run an "update_cache" command or something? This seems impractical to me, but then again, what would I know?
Re: RealityRP [RP][C#][PHP][R63]
Quote:
Originally Posted by
Roper
This sounds like a ridiculous idea, are you caching everything in the users table or just specific things?
Lets say a user signs up, but the emulator has already cached the users so how would the new user log in? Would a member of staff have to run an "update_cache" command or something? This seems impractical to me, but then again, what would I know?
The best idea is:
On authenticating, check if a dictionary / hashtable contains the user ID, if it does, return that value, else load from database and then add.
Re: RealityRP [RP][C#][PHP][R63]
Quote:
Originally Posted by
Roper
This sounds like a ridiculous idea, are you caching everything in the users table or just specific things?
Lets say a user signs up, but the emulator has already cached the users so how would the new user log in? Would a member of staff have to run an "update_cache" command or something? This seems impractical to me, but then again, what would I know?
What I mean when I said caching users is:
The users data will be cached upon login.
You dont do "GET username FROM players WHERE id = '202'" every time
All the data will be stored that is needed to be stored (like usernames, id's, things that are static (don't change often or don't change at all))
FOLLOW US ON FACEBOOK
https://www.facebook.com/RealityRP2
Re: RealityRP [RP][C#][PHP][R63]
Quote:
Originally Posted by
Tha
The best idea is:
On authenticating, check if a dictionary / hashtable contains the user ID, if it does, return that value, else load from database and then add.
Yeah, I can see this may be useful but would it really be as efficient as he's making it out to be?
Quote:
Originally Posted by
Divide
What I mean when I said caching users is:
The users data will be cached upon login.
You dont do "GET username FROM players WHERE id = '202'" every time
All the data will be stored that is needed to be stored (like usernames, id's, things that are static (don't change often or don't change at all))
FOLLOW US ON FACEBOOK
https://www.facebook.com/RealityRP2
This seems logical.
Re: RealityRP [RP][C#][PHP][R63]
Quote:
Originally Posted by
Roper
Yeah, I can see this may be useful but would it really be as efficient as he's making it out to be?
This seems logical.
If he's doing it correctly, yes, else I'm just going to cry silently.
But well Ben, hopefully it will turn out well, are you using stable Socket pooling, or you still use BeginAccept/BeginReceive shit?
Re: RealityRP [RP][C#][PHP][R63]
I may be wrong here but don't you need the connection open all the time, and not keep opening it and closing it on function usage.
Still learning C# so don't blame me if im wrong lol
PHP Code:
namespace Reality.Database
{
using MySql.Data.MySqlClient;
using Reality;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;
internal class Database
{
private MySqlConnection connection;
private string database;
private string password;
private string server;
private string uid;
public Database(string host, string username, string password, string database)
{
this.Initialize(host, username, password, database);
}
public void Backup()
{
try
{
DateTime now = DateTime.Now;
int year = now.Year;
int month = now.Month;
int day = now.Day;
int hour = now.Hour;
int minute = now.Minute;
int second = now.Second;
int millisecond = now.Millisecond;
StreamWriter writer = new StreamWriter(string.Concat(new object[] { @"C:\MySqlBackup", year, "-", month, "-", day, "-", hour, "-", minute, "-", second, "-", millisecond, ".sql" }));
ProcessStartInfo startInfo = new ProcessStartInfo {
FileName = "mysqldump",
RedirectStandardInput = false,
RedirectStandardOutput = true,
Arguments = string.Format("-u{0} -p{1} -h{2} {3}", new object[] { this.uid, this.password, this.server, this.database }),
UseShellExecute = false
};
Process process = Process.Start(startInfo);
string str2 = process.StandardOutput.ReadToEnd();
writer.WriteLine(str2);
process.WaitForExit();
writer.Close();
process.Close();
}
catch (Exception)
{
MessageBox.Show("Error , unable to backup!");
}
}
private bool CloseConnection()
{
try
{
this.connection.Close();
return true;
}
catch (MySqlException exception)
{
MessageBox.Show(exception.Message);
return false;
}
}
public int Count()
{
string cmdText = "SELECT Count(*) FROM tableinfo";
int num = -1;
if (this.OpenConnection())
{
num = int.Parse(new MySqlCommand(cmdText, this.connection).ExecuteScalar());
this.CloseConnection();
return num;
}
return num;
}
public void Delete()
{
string cmdText = "DELETE FROM tableinfo WHERE name='John Smith'";
if (this.OpenConnection())
{
new MySqlCommand(cmdText, this.connection).ExecuteNonQuery();
this.CloseConnection();
}
}
private void Initialize(string host, string username, string password, string database)
{
this.server = host;
this.uid = username;
this.password = password;
this.database = database;
string connectionString = "SERVER=" + this.server + ";DATABASE=" + database + ";UID=" + this.uid + ";PASSWORD=" + password + ";";
this.connection = new MySqlConnection(connectionString);
this.OpenConnection();
}
public void Insert()
{
string cmdText = "INSERT INTO tableinfo (name, age) VALUES('John Smith', '33')";
if (this.OpenConnection())
{
new MySqlCommand(cmdText, this.connection).ExecuteNonQuery();
this.CloseConnection();
}
}
private bool OpenConnection()
{
try
{
this.connection.Open();
return true;
}
catch (MySqlException exception)
{
Program.Error(exception.Message.ToString());
return false;
}
}
public void Restore()
{
try
{
string path = @"C:\MySqlBackup.sql";
StreamReader reader = new StreamReader(path);
string str2 = reader.ReadToEnd();
reader.Close();
ProcessStartInfo startInfo = new ProcessStartInfo {
FileName = "mysql",
RedirectStandardInput = true,
RedirectStandardOutput = false,
Arguments = string.Format("-u{0} -p{1} -h{2} {3}", new object[] { this.uid, this.password, this.server, this.database }),
UseShellExecute = false
};
Process process = Process.Start(startInfo);
process.StandardInput.WriteLine(str2);
process.StandardInput.Close();
process.WaitForExit();
process.Close();
}
catch (Exception)
{
MessageBox.Show("Error , unable to Restore!");
}
}
public List<string>[] Select()
{
string cmdText = "SELECT * FROM tableinfo";
List<string>[] listArray = new List<string>[] { new List<string>(), new List<string>(), new List<string>() };
if (this.OpenConnection())
{
MySqlDataReader reader = new MySqlCommand(cmdText, this.connection).ExecuteReader();
while (reader.Read())
{
listArray[0].Add(reader["id"]);
listArray[1].Add(reader["name"]);
listArray[2].Add(reader["age"]);
}
reader.Close();
this.CloseConnection();
return listArray;
}
return listArray;
}
public void Update()
{
string str = "UPDATE tableinfo SET name='Joe', age='22' WHERE name='John Smith'";
if (this.OpenConnection())
{
new MySqlCommand { CommandText = str, Connection = this.connection }.ExecuteNonQuery();
this.CloseConnection();
}
}
}
}
Re: RealityRP [RP][C#][PHP][R63]
Quote:
Originally Posted by
Clawed
I may be wrong here but don't you need the connection open all the time, and not keep opening it and closing it on function usage.
Still learning C# so don't blame me if im wrong lol
PHP Code:
namespace Reality.Database
{
using MySql.Data.MySqlClient;
using Reality;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;
internal class Database
{
private MySqlConnection connection;
private string database;
private string password;
private string server;
private string uid;
public Database(string host, string username, string password, string database)
{
this.Initialize(host, username, password, database);
}
public void Backup()
{
try
{
DateTime now = DateTime.Now;
int year = now.Year;
int month = now.Month;
int day = now.Day;
int hour = now.Hour;
int minute = now.Minute;
int second = now.Second;
int millisecond = now.Millisecond;
StreamWriter writer = new StreamWriter(string.Concat(new object[] { @"C:\MySqlBackup", year, "-", month, "-", day, "-", hour, "-", minute, "-", second, "-", millisecond, ".sql" }));
ProcessStartInfo startInfo = new ProcessStartInfo {
FileName = "mysqldump",
RedirectStandardInput = false,
RedirectStandardOutput = true,
Arguments = string.Format("-u{0} -p{1} -h{2} {3}", new object[] { this.uid, this.password, this.server, this.database }),
UseShellExecute = false
};
Process process = Process.Start(startInfo);
string str2 = process.StandardOutput.ReadToEnd();
writer.WriteLine(str2);
process.WaitForExit();
writer.Close();
process.Close();
}
catch (Exception)
{
MessageBox.Show("Error , unable to backup!");
}
}
private bool CloseConnection()
{
try
{
this.connection.Close();
return true;
}
catch (MySqlException exception)
{
MessageBox.Show(exception.Message);
return false;
}
}
public int Count()
{
string cmdText = "SELECT Count(*) FROM tableinfo";
int num = -1;
if (this.OpenConnection())
{
num = int.Parse(new MySqlCommand(cmdText, this.connection).ExecuteScalar());
this.CloseConnection();
return num;
}
return num;
}
public void Delete()
{
string cmdText = "DELETE FROM tableinfo WHERE name='John Smith'";
if (this.OpenConnection())
{
new MySqlCommand(cmdText, this.connection).ExecuteNonQuery();
this.CloseConnection();
}
}
private void Initialize(string host, string username, string password, string database)
{
this.server = host;
this.uid = username;
this.password = password;
this.database = database;
string connectionString = "SERVER=" + this.server + ";DATABASE=" + database + ";UID=" + this.uid + ";PASSWORD=" + password + ";";
this.connection = new MySqlConnection(connectionString);
this.OpenConnection();
}
public void Insert()
{
string cmdText = "INSERT INTO tableinfo (name, age) VALUES('John Smith', '33')";
if (this.OpenConnection())
{
new MySqlCommand(cmdText, this.connection).ExecuteNonQuery();
this.CloseConnection();
}
}
private bool OpenConnection()
{
try
{
this.connection.Open();
return true;
}
catch (MySqlException exception)
{
Program.Error(exception.Message.ToString());
return false;
}
}
public void Restore()
{
try
{
string path = @"C:\MySqlBackup.sql";
StreamReader reader = new StreamReader(path);
string str2 = reader.ReadToEnd();
reader.Close();
ProcessStartInfo startInfo = new ProcessStartInfo {
FileName = "mysql",
RedirectStandardInput = true,
RedirectStandardOutput = false,
Arguments = string.Format("-u{0} -p{1} -h{2} {3}", new object[] { this.uid, this.password, this.server, this.database }),
UseShellExecute = false
};
Process process = Process.Start(startInfo);
process.StandardInput.WriteLine(str2);
process.StandardInput.Close();
process.WaitForExit();
process.Close();
}
catch (Exception)
{
MessageBox.Show("Error , unable to Restore!");
}
}
public List<string>[] Select()
{
string cmdText = "SELECT * FROM tableinfo";
List<string>[] listArray = new List<string>[] { new List<string>(), new List<string>(), new List<string>() };
if (this.OpenConnection())
{
MySqlDataReader reader = new MySqlCommand(cmdText, this.connection).ExecuteReader();
while (reader.Read())
{
listArray[0].Add(reader["id"]);
listArray[1].Add(reader["name"]);
listArray[2].Add(reader["age"]);
}
reader.Close();
this.CloseConnection();
return listArray;
}
return listArray;
}
public void Update()
{
string str = "UPDATE tableinfo SET name='Joe', age='22' WHERE name='John Smith'";
if (this.OpenConnection())
{
new MySqlCommand { CommandText = str, Connection = this.connection }.ExecuteNonQuery();
this.CloseConnection();
}
}
}
}
No, opening the MySqlConnection object once is enough. It would be useless to open it every time a new Query occurs, and it will lag like hell.
What to do:
Emu startup -> MySqlConnection open
New Query -> Create MySqlCommand and execute query
Emu close -> MySqlConnection will close automatically
That's way better than opening the connection everytime you run a query, sometimes it can take up to 3 seconds to open a MySqlConnection, imagine 400 people doing a query at the same time..
Re: RealityRP [RP][C#][PHP][R63]
Quote:
Originally Posted by
Clawed
I may be wrong here but don't you need the connection open all the time, and not keep opening it and closing it on function usage.
Still learning C# so don't blame me if im wrong lol
PHP Code:
namespace Reality.Database
{
using MySql.Data.MySqlClient;
using Reality;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;
internal class Database
{
private MySqlConnection connection;
private string database;
private string password;
private string server;
private string uid;
public Database(string host, string username, string password, string database)
{
this.Initialize(host, username, password, database);
}
public void Backup()
{
try
{
DateTime now = DateTime.Now;
int year = now.Year;
int month = now.Month;
int day = now.Day;
int hour = now.Hour;
int minute = now.Minute;
int second = now.Second;
int millisecond = now.Millisecond;
StreamWriter writer = new StreamWriter(string.Concat(new object[] { @"C:\MySqlBackup", year, "-", month, "-", day, "-", hour, "-", minute, "-", second, "-", millisecond, ".sql" }));
ProcessStartInfo startInfo = new ProcessStartInfo {
FileName = "mysqldump",
RedirectStandardInput = false,
RedirectStandardOutput = true,
Arguments = string.Format("-u{0} -p{1} -h{2} {3}", new object[] { this.uid, this.password, this.server, this.database }),
UseShellExecute = false
};
Process process = Process.Start(startInfo);
string str2 = process.StandardOutput.ReadToEnd();
writer.WriteLine(str2);
process.WaitForExit();
writer.Close();
process.Close();
}
catch (Exception)
{
MessageBox.Show("Error , unable to backup!");
}
}
private bool CloseConnection()
{
try
{
this.connection.Close();
return true;
}
catch (MySqlException exception)
{
MessageBox.Show(exception.Message);
return false;
}
}
public int Count()
{
string cmdText = "SELECT Count(*) FROM tableinfo";
int num = -1;
if (this.OpenConnection())
{
num = int.Parse(new MySqlCommand(cmdText, this.connection).ExecuteScalar());
this.CloseConnection();
return num;
}
return num;
}
public void Delete()
{
string cmdText = "DELETE FROM tableinfo WHERE name='John Smith'";
if (this.OpenConnection())
{
new MySqlCommand(cmdText, this.connection).ExecuteNonQuery();
this.CloseConnection();
}
}
private void Initialize(string host, string username, string password, string database)
{
this.server = host;
this.uid = username;
this.password = password;
this.database = database;
string connectionString = "SERVER=" + this.server + ";DATABASE=" + database + ";UID=" + this.uid + ";PASSWORD=" + password + ";";
this.connection = new MySqlConnection(connectionString);
this.OpenConnection();
}
public void Insert()
{
string cmdText = "INSERT INTO tableinfo (name, age) VALUES('John Smith', '33')";
if (this.OpenConnection())
{
new MySqlCommand(cmdText, this.connection).ExecuteNonQuery();
this.CloseConnection();
}
}
private bool OpenConnection()
{
try
{
this.connection.Open();
return true;
}
catch (MySqlException exception)
{
Program.Error(exception.Message.ToString());
return false;
}
}
public void Restore()
{
try
{
string path = @"C:\MySqlBackup.sql";
StreamReader reader = new StreamReader(path);
string str2 = reader.ReadToEnd();
reader.Close();
ProcessStartInfo startInfo = new ProcessStartInfo {
FileName = "mysql",
RedirectStandardInput = true,
RedirectStandardOutput = false,
Arguments = string.Format("-u{0} -p{1} -h{2} {3}", new object[] { this.uid, this.password, this.server, this.database }),
UseShellExecute = false
};
Process process = Process.Start(startInfo);
process.StandardInput.WriteLine(str2);
process.StandardInput.Close();
process.WaitForExit();
process.Close();
}
catch (Exception)
{
MessageBox.Show("Error , unable to Restore!");
}
}
public List<string>[] Select()
{
string cmdText = "SELECT * FROM tableinfo";
List<string>[] listArray = new List<string>[] { new List<string>(), new List<string>(), new List<string>() };
if (this.OpenConnection())
{
MySqlDataReader reader = new MySqlCommand(cmdText, this.connection).ExecuteReader();
while (reader.Read())
{
listArray[0].Add(reader["id"]);
listArray[1].Add(reader["name"]);
listArray[2].Add(reader["age"]);
}
reader.Close();
this.CloseConnection();
return listArray;
}
return listArray;
}
public void Update()
{
string str = "UPDATE tableinfo SET name='Joe', age='22' WHERE name='John Smith'";
if (this.OpenConnection())
{
new MySqlCommand { CommandText = str, Connection = this.connection }.ExecuteNonQuery();
this.CloseConnection();
}
}
}
}
Ahh, Thanks for your help.
Todays updates:
- Recoded MySQL connections
- Started to code Sockets
Quote:
Originally Posted by
Tha
But well Ben, hopefully it will turn out well, are you using stable Socket pooling, or you still use BeginAccept/BeginReceive shit?
I will look into as many socket pooling ideas I can think off to make this emulator the best it can be.
I want to take over these shit renames such as Rainduck RP, LifeRP, AtomRP.
I have the motivation, You guys have the support. LETS DO THIS THING!
Re: RealityRP [RP][C#][PHP][R63]
Quote:
Originally Posted by
Divide
Ahh, Thanks for your help.
Todays updates:
- Recoded MySQL connections
- Started to code Sockets
I will look into as many socket pooling ideas I can think off to make this emulator the best it can be.
I want to take over these shit renames such as Rainduck RP, LifeRP, AtomRP.
I have the motivation, You guys have the support. LETS DO THIS THING!
Your attitude.. Ben.. I simply love it, good luck, I support you all the way down to London Town!
Re: RealityRP [RP][C#][PHP][R63]
Quote:
Originally Posted by
Tha
Your attitude.. Ben.. I simply love it, good luck, I support you all the way down to London Town!
Aha, Thanks mate :D
BTW are these good sockets to use? Was googling and saw it's pretty recent:
http://forum.ragezone.com/f353/starl...-0-1-a-920078/
Re: RealityRP [RP][C#][PHP][R63]
I'd recommend SuperSockets.
Re: RealityRP [RP][C#][PHP][R63]
Quote:
Originally Posted by
vLife
Welldone, You got my first (and probably only) ever like!
Will use these. Look amazing :D