Shrink packet header size
This commit is contained in:
1 parent
c3906e7d60
commit
7b58ca0338
10 files changed
+140
-115
No files matched your search
@@ -28,7 +28,7 @@ namespace MistoxServer {
|
||||
Console.WriteLine( "The client is initilized and trying to connect to the server at ip : " + mPEndPoint.Address );
|
||||
// Make a UDP connection to the server
|
||||
try {
|
||||
FastUpdate = new mUDPClient( mPEndPoint, ServerMode.Authoritative );
|
||||
FastUpdate = new mUDPClient( mPEndPoint );
|
||||
FastUpdate.onReceived += (object o, EventArgs e) => { onFastReceive?.Invoke( o, e ); };
|
||||
} catch( Exception e ) {
|
||||
Console.WriteLine( "An error has occured with the connection to the server. Error { " );
|
||||
|
||||
@@ -3,12 +3,15 @@ using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MistoxServer {
|
||||
public partial class mServer {
|
||||
public static IMistoxServer newServer(int port, ServerMode mode) {
|
||||
return new ServerInterface(port, mode);
|
||||
public class mServer {
|
||||
|
||||
public static IMistoxServer newServer(int port) {
|
||||
DataPacket.BuildNetworkPacketList();
|
||||
return new ServerInterface(port);
|
||||
}
|
||||
|
||||
public static IMistoxServer newClient(string ServerIPOrHostName, int Port) {
|
||||
DataPacket.BuildNetworkPacketList();
|
||||
int index = 0;
|
||||
IPAddress[] remoteAddress = Dns.GetHostAddresses(ServerIPOrHostName);
|
||||
for( int i=0; i< remoteAddress.Length; i++ ) {
|
||||
@@ -24,17 +27,16 @@ namespace MistoxServer {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public interface IMistoxServer {
|
||||
|
||||
public event EventHandler onConnected;
|
||||
public event EventHandler onSlowReceive;
|
||||
public event EventHandler onFastReceive;
|
||||
public event EventHandler onDisconnected;
|
||||
|
||||
public Task Send<Packet>(Packet data, SendType speed);
|
||||
|
||||
}
|
||||
|
||||
public enum SendType {
|
||||
@@ -42,9 +44,4 @@ namespace MistoxServer {
|
||||
FastUpdate
|
||||
}
|
||||
|
||||
public enum ServerMode {
|
||||
Passive,
|
||||
Authoritative
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,21 +17,23 @@ namespace MistoxServer {
|
||||
public event EventHandler onFastReceive;
|
||||
public event EventHandler onDisconnected;
|
||||
|
||||
public ServerInterface( int port, ServerMode mode ) {
|
||||
FastUpdateServer = new mUDPClient( new IPEndPoint( IPAddress.IPv6Any, port ), mode );
|
||||
SlowUpdateServer = new mTCPListener( port, mode );
|
||||
public ServerInterface( int port ) {
|
||||
|
||||
// Initilize the server listening connections
|
||||
SlowUpdateServer = new mTCPListener( port );
|
||||
SlowUpdateServer.onConnected += OnConnected;
|
||||
FastUpdateServer.onReceived += ( object o, EventArgs e ) => { onFastReceive?.Invoke( o, e ); };
|
||||
SlowUpdateServer.onDisconnected += OnDisconnected;
|
||||
|
||||
FastUpdateServer = new mUDPClient( new IPEndPoint( IPAddress.Any, port ) );
|
||||
FastUpdateServer.onReceived += ( object o, EventArgs e ) => { onFastReceive?.Invoke( o, e ); };
|
||||
|
||||
Console.WriteLine( "The Server is initilized and waiting for clients to connect at port : " + port );
|
||||
}
|
||||
|
||||
void OnConnected( object sender, EventArgs e ) {
|
||||
Connection user = (Connection)sender;
|
||||
onConnected?.Invoke( sender, e );
|
||||
user.slowClient.onReceived+= ( object o, EventArgs e ) => { onSlowReceive?.Invoke( o, e ); };
|
||||
user.slowClient.onReceived += ( object o, EventArgs e ) => { onSlowReceive?.Invoke( o, e ); };
|
||||
user.slowClient.onDisconnected += OnDisconnected;
|
||||
Connections.Add( user );
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user