- put server in Game - created start server function in Game - created CommandRestart There are two different 'player classes' which do I use? PlayerBasic and BasePlayer.
67 lines
1.4 KiB
C#
67 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Net;
|
|
using System.Net.Sockets;
|
|
|
|
// TODO: Make ClientSocket a friend of ServerSocket so I can make sock and type private
|
|
// other, havn't thought of what else I need
|
|
|
|
namespace MudEngine.Networking
|
|
{
|
|
class ClientSocket
|
|
{
|
|
public ClientSocket()
|
|
{
|
|
type = 0;
|
|
}
|
|
~ClientSocket()
|
|
{
|
|
type = 0;
|
|
}
|
|
public int Send(byte[] ba)
|
|
{
|
|
try
|
|
{
|
|
sock.Send(ba);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return -1;
|
|
}
|
|
return 1;
|
|
}
|
|
public int Receive(byte[] ba)
|
|
{
|
|
try
|
|
{
|
|
sock.Receive(ba);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return -1;
|
|
}
|
|
return 1;
|
|
}
|
|
public int CleanUp()
|
|
{
|
|
try
|
|
{
|
|
sock.Disconnect(true);
|
|
sock.Close();
|
|
sock.Dispose();
|
|
type = 0;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return -1;
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
public ProtocolType type;
|
|
public IPAddress ip;
|
|
public Socket sock;
|
|
}
|
|
}
|