mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-04-20 11:47:48 +00:00
Added log code.
This commit is contained in:
parent
7834b737eb
commit
9dfd6906b9
5 changed files with 70 additions and 15 deletions
|
@ -56,7 +56,7 @@ namespace FFXIVClassic_Lobby_Server
|
|||
socket.Send(packetBytes);
|
||||
}
|
||||
catch(Exception e)
|
||||
{ Debug.WriteLine("Weird case, socket was d/ced: {0}", e); }
|
||||
{ Log.error(String.Format("Weird case, socket was d/ced: {0}", e)); }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="common\Log.cs" />
|
||||
<Compile Include="dataobjects\Retainer.cs" />
|
||||
<Compile Include="dataobjects\Character.cs" />
|
||||
<Compile Include="ClientConnection.cs" />
|
||||
|
|
|
@ -233,37 +233,37 @@ namespace FFXIVClassic_Lobby_Server
|
|||
|
||||
if (alreadyTaken)
|
||||
{
|
||||
ErrorPacket errorPacket = new ErrorPacket(charaReq.sequence, 0, 0, 13005, "");
|
||||
ErrorPacket errorPacket = new ErrorPacket(charaReq.sequence, 0xBDB, 0, 13005, "");
|
||||
SubPacket subpacket = errorPacket.buildPacket();
|
||||
BasePacket basePacket = BasePacket.createPacket(subpacket, true, false);
|
||||
BasePacket.encryptPacket(client.blowfish, basePacket);
|
||||
client.queuePacket(basePacket);
|
||||
|
||||
Console.WriteLine("User {0} => Error; name taken: \"{1}\"", client.currentUserId, charaReq.characterName);
|
||||
Log.info(String.Format("User {0} => Error; name taken: \"{1}\"", client.currentUserId, charaReq.characterName));
|
||||
return;
|
||||
}
|
||||
|
||||
Console.WriteLine("User {0} => Character reserved \"{1}\"", client.currentUserId, charaReq.characterName);
|
||||
Log.info(String.Format("User {0} => Character reserved \"{1}\"", client.currentUserId, charaReq.characterName));
|
||||
break;
|
||||
case 0x02://Make
|
||||
Character character = Character.EncodedToCharacter(charaReq.characterInfoEncoded);
|
||||
|
||||
Database.makeCharacter(client.currentUserId, name, character);
|
||||
|
||||
Console.WriteLine("User {0} => Character created \"{1}\"", client.currentUserId, charaReq.characterName);
|
||||
Log.info(String.Format("User {0} => Character created \"{1}\"", client.currentUserId, charaReq.characterName));
|
||||
break;
|
||||
case 0x03://Rename
|
||||
|
||||
Console.WriteLine("User {0} => Character renamed \"{1}\"", client.currentUserId, charaReq.characterName);
|
||||
Log.info(String.Format("User {0} => Character renamed \"{1}\"", client.currentUserId, charaReq.characterName));
|
||||
break;
|
||||
case 0x04://Delete
|
||||
Database.deleteCharacter(charaReq.characterId, charaReq.characterName);
|
||||
|
||||
Console.WriteLine("User {0} => Character deleted \"{1}\"", client.currentUserId, charaReq.characterName);
|
||||
Log.info(String.Format("User {0} => Character deleted \"{1}\"", client.currentUserId, charaReq.characterName));
|
||||
break;
|
||||
case 0x06://Rename Retainer
|
||||
|
||||
Console.WriteLine("User {0} => Retainer renamed \"{1}\"", client.currentUserId, charaReq.characterName);
|
||||
Log.info(String.Format("User {0} => Retainer renamed \"{1}\"", client.currentUserId, charaReq.characterName));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ using System.Net;
|
|||
using System.Net.Sockets;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
using FFXIVClassic_Lobby_Server.common;
|
||||
|
||||
namespace FFXIVClassic_Lobby_Server
|
||||
{
|
||||
|
@ -78,7 +79,7 @@ namespace FFXIVClassic_Lobby_Server
|
|||
conn.socket.BeginReceive(conn.buffer, 0, conn.buffer.Length, SocketFlags.None, new AsyncCallback(receiveCallback), conn);
|
||||
//Queue the accept of the next incomming connection
|
||||
mServerSocket.BeginAccept(new AsyncCallback(acceptCallback), mServerSocket);
|
||||
Console.WriteLine("Connection {0}:{1} has connected.", (conn.socket.RemoteEndPoint as IPEndPoint).Address, (conn.socket.RemoteEndPoint as IPEndPoint).Port);
|
||||
Log.conn(String.Format("Connection {0}:{1} has connected.", (conn.socket.RemoteEndPoint as IPEndPoint).Address, (conn.socket.RemoteEndPoint as IPEndPoint).Port));
|
||||
}
|
||||
catch (SocketException)
|
||||
{
|
||||
|
@ -121,7 +122,7 @@ namespace FFXIVClassic_Lobby_Server
|
|||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("{0} has disconnected.", conn.currentUserId == 0 ? conn.getAddress() : "User " + conn.currentUserId);
|
||||
Log.conn(String.Format("{0} has disconnected.", conn.currentUserId == 0 ? conn.getAddress() : "User " + conn.currentUserId));
|
||||
conn.socket.Close();
|
||||
lock (mConnectionList)
|
||||
{
|
||||
|
@ -133,7 +134,7 @@ namespace FFXIVClassic_Lobby_Server
|
|||
{
|
||||
if (conn.socket != null)
|
||||
{
|
||||
Console.WriteLine("Connection @ {0} has disconnected.", conn.currentUserId == 0 ? "Unknown User " : "User " + conn.currentUserId);
|
||||
Log.conn(String.Format("Connection @ {0} has disconnected.", conn.currentUserId == 0 ? "Unknown User " : "User " + conn.currentUserId));
|
||||
conn.socket.Close();
|
||||
lock (mConnectionList)
|
||||
{
|
||||
|
@ -145,8 +146,5 @@ namespace FFXIVClassic_Lobby_Server
|
|||
|
||||
#endregion
|
||||
|
||||
#region Packet Handling
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
|
56
FFXIVClassic_Lobby_Server/common/Log.cs
Normal file
56
FFXIVClassic_Lobby_Server/common/Log.cs
Normal file
|
@ -0,0 +1,56 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FFXIVClassic_Lobby_Server.common
|
||||
{
|
||||
class Log
|
||||
{
|
||||
public static void error(String message)
|
||||
{
|
||||
Console.Write("[{0}]", DateTime.Now.ToString("dd/MMM HH:mm"));
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.Write("[ERROR]");
|
||||
Console.ForegroundColor = ConsoleColor.Gray ;
|
||||
Console.WriteLine(message);
|
||||
}
|
||||
|
||||
public static void debug(String message)
|
||||
{
|
||||
Console.Write("[{0}]", DateTime.Now.ToString("dd/MMM HH:mm"));
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
Console.Write("[DEBUG]");
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
Console.WriteLine(message);
|
||||
}
|
||||
|
||||
public static void info(String message)
|
||||
{
|
||||
Console.Write("[{0}]", DateTime.Now.ToString("dd/MMM HH:mm"));
|
||||
Console.ForegroundColor = ConsoleColor.Cyan;
|
||||
Console.Write("[INFO]");
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
Console.WriteLine(message);
|
||||
}
|
||||
|
||||
public static void database(String message)
|
||||
{
|
||||
Console.Write("[{0}]", DateTime.Now.ToString("dd/MMM HH:mm"));
|
||||
Console.ForegroundColor = ConsoleColor.Magenta;
|
||||
Console.Write("[SQL]");
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
Console.WriteLine(message);
|
||||
}
|
||||
|
||||
public static void conn(String message)
|
||||
{
|
||||
Console.Write("[{0}]", DateTime.Now.ToString("dd/MMM HH:mm"));
|
||||
Console.ForegroundColor = ConsoleColor.DarkGreen;
|
||||
Console.Write("[CONN]");
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
Console.WriteLine(message);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue