CoEmu v2 Plyz Need help faster

05/27/2009 18:51 sawickas#1
/*
* Created by SharpDevelop.
* User: sams
* Date: 3/8/2009
* Time: 1:13 PM
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using MySql.Data.MySqlClient;

namespace CoEmu_v2_GameServer.Database
{
/// <summary>
/// Provides MySql resource connections, for multiple connections to a single MySql database.
/// This is due to the fact that the server is multi-threaded, so allowing a single connection would
/// likely result in errors, or general loss of performance.
/// </summary>
public static class DatabaseConnection
{
public const string USER_NAME = "root";
public const string PASSWORD = "test";
public const string SERVER = "127.0.0.1";
public const string DATA_BASE = "conqueremu";
public static MySqlConnection NewConnection()
{
MySqlConnection C = null;
try{
C = new MySqlConnection("Server=" + SERVER + ";Database='" + DATA_BASE + "';Username='" + USER_NAME + "';Password='" + PASSWORD + "'; Min Pool Size = 300; Max Pool Size = 900");
C.Open();
}
catch(Exception e)
{
Console.WriteLine(e.ToString());
return null;
}
return C;
}
}
}



















/*
* Created by SharpDevelop.
* User: sams
* Date: 3/4/2009
* Time: 5:37 PM
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using CoEmu_v2_GameServer.Connections;

namespace CoEmu_v2_GameServer.Connections
{
/// <summary>
/// The Master socket thread.
/// </summary>
public class MasterSocket
{
protected Socket ServerSocket;
protected const int LOGIN_PORT = 9958;
protected const string SERVER_IP = "127.0.0.1";
protected const string SITE_IP = "127.0.0.1";
protected const int AUTH_PORT = 5817;
protected const int GAME_PORT = 5816;
protected string ServerName;
protected static bool Continue = true;

public MasterSocket(string name)
{
ServerName = name;
if(name == "GameServer")
{
ServerSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IPEndPoint IPE = new IPEndPoint(new IPAddress(0), GAME_PORT);
try{
ServerSocket.Bind(IPE);
}
catch(Exception e)
{
Console.WriteLine("["+name+"-Init] Failed, unable to bind server to socket.");
Console.WriteLine(e.StackTrace);
System.Environment.Exit(-1);
}
}
else if(name == "AuthServer")
{
ServerSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IPEndPoint IPE = new IPEndPoint(new IPAddress(0), AUTH_PORT);
try{
ServerSocket.Bind(IPE);
}
catch(Exception e)
{
Console.WriteLine("["+name+"-Init] Failed, unable to bind server to socket.");
Console.WriteLine(e.StackTrace);
System.Environment.Exit(-1);
}
}
}

public void AcceptNewConnections()
{
ServerSocket.Listen(100);
while(Continue)
{
if(ServerName == "GameServer")
{
Socket CSocket = null;
try{
CSocket = ServerSocket.Accept();
}
catch(Exception e)
{
Console.WriteLine("Unable to accept a new connection, closing now.");
ServerSocket.Close();
Console.WriteLine(e.StackTrace);
return;
}
try
{
if(CSocket.Connected)
{
if(!CSocket.RemoteEndPoint.ToString().Contains(SIT E_IP))
{
ClientSocket CS = new ClientSocket(CSocket);
new Thread(CS.Run).Start();
}
else
{
CSocket.Close();
}
}
}
catch(Exception e)
{
if(CSocket != null)
CSocket.Close();
Console.WriteLine("[GameServer] Unable to login a new client, see exception print below.");
Console.WriteLine(e.ToString());
}
}
else if(ServerName == "AuthServer")
{
Socket ASocket = null;
try{
ASocket = ServerSocket.Accept();
}
catch(Exception e)
{
Console.WriteLine("Unable to accept data from Auth Server.");
ServerSocket.Close();
Console.WriteLine(e.ToString());
return;
}
if(ASocket != null)
{
try{
//AuthHandler.NewAuth(ASocket);
byte[] Buffer = new byte[8092];
int size = ASocket.Receive(Buffer);
byte[] Data = new byte[size];
Array.Copy(Buffer, Data, size);
AuthHandler.HandleAuth(Data);
Data = null;
Buffer = null;
}
catch(Exception e)
{
Console.WriteLine(e.ToString());
}
}
}
System.Threading.Thread.Sleep(200);
}
}
public void Close()
{
Console.WriteLine("["+ServerName+"-End] Closing Socket.");
ServerSocket.Close();
Continue = false;
if(ServerName == "GameServer")
{
Nano.Continue = false;
}
}
}
}














Datebase eroor Line 34 Maby sombary can help my? paste here configs For Onli local PC Plyzzzzzz :(