Functions.LogOutputToConsole
=
LogType.Track;
string
dbstring
=
"
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=
"
;
dbstring
+=
Smark.Core.Functions.GetPath(
typeof
(Program).Assembly);
dbstring
+=
"
Northwind.mdb
"
;
DBContext.SetConnectionString(ConnectionType.Context1, dbstring);
TcpServer
<
TcpClient
<
EofAtEnter
>>
server
=
new
TcpServer
<
TcpClient
<
EofAtEnter
>>
();
server.ClientConnected
+=
(o, e)
=>
{
Functions.WriteLog(LogType.Track,
typeof
(Program),
"
{0} On Connected \t {1}
"
, e.Client.Name,DateTime.Now);
};
server.ClientDisposed
+=
(o, e)
=>
{
Functions.WriteLog(LogType.Track,
typeof
(Program),
"
{0} On Disposed \t {1}
"
, e.Client.Name,DateTime.Now);
};
server.ClientError
+=
(o, e)
=>
{
Functions.WriteLog(LogType.Track,
typeof
(Program),
"
{0} On Error:{1} \t {2}
"
, e.Client.Name,e.Exception.Message, DateTime.Now);
};
server.ClientReceive
+=
(o, e)
=>
{
try
{
Modules.Command cmd
=
(Modules.Command)Functions.DeserializeObject(e.Buffer.Data, e.Buffer.Count
-
2
);
Execute(cmd,e.Client);
}
catch
(Exception e_)
{
Functions.WriteLog(LogType.Track,
typeof
(Program),
"
{0} Data Error:{1} \t {2}
"
, e.Client.Name, e_.Message, DateTime.Now);
e.Client.Dispose();
}
};
server.Open(Functions.AppSettingValue(
"
ip
"
),Functions.AppSettingValue
<
int
>
(
"
port
"
),
100
);
Functions.WriteLog(LogType.Track,
typeof
(Program),
"
SocketAsyncsForNorthwind.ServerApp Start \t {0}
"
,DateTime.Now);
Console.Read();