Cleanup unnessisary interface classes
This commit is contained in:
1 parent
b83887cb2a
commit
46efb5bd65
8 files changed
+58
-117
No files matched your search
@@ -1,17 +1,30 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using Mistox.Attributes;
|
||||
using Mistox.Client;
|
||||
using Mistox.Server;
|
||||
|
||||
namespace Mistox {
|
||||
public class mServer {
|
||||
public class GameServer {
|
||||
|
||||
public static ServerInterface newServer( string serverName, int port ) {
|
||||
public static MistoxServer newServer( string serverName, int port ) {
|
||||
|
||||
// Build the network packet list
|
||||
NetworkPacketDictionary.BuildNetworkPacketList();
|
||||
return new ServerInterface(port, serverName);
|
||||
|
||||
// Set the listener address
|
||||
IPEndPoint listenerAddress = new IPEndPoint( IPAddress.Any, port );
|
||||
|
||||
// Return the initlized server instance
|
||||
return new MistoxServer(listenerAddress, serverName);
|
||||
}
|
||||
|
||||
public static ClientInterface newClient( string UserName, string ServerIPOrHostName, int Port, string ConnectionKey = "" ) {
|
||||
public static MistoxClient newClient( string UserName, string ServerIPOrHostName, int Port, string ConnectionKey = "" ) {
|
||||
|
||||
// Build the network packet list
|
||||
NetworkPacketDictionary.BuildNetworkPacketList();
|
||||
|
||||
// Get the remote IP from the DNSName
|
||||
int index = 0;
|
||||
IPAddress[] remoteAddress = Dns.GetHostAddresses(ServerIPOrHostName);
|
||||
for( int i=0; i< remoteAddress.Length; i++ ) {
|
||||
@@ -20,13 +33,25 @@ namespace Mistox {
|
||||
}
|
||||
}
|
||||
string ipAddress = remoteAddress[index].ToString();
|
||||
if ( remoteAddress.Length > 0) {
|
||||
return new ClientInterface(UserName, ConnectionKey, ipAddress, Port);
|
||||
} else {
|
||||
|
||||
// If a remote address exists
|
||||
if ( remoteAddress.Length == 0) {
|
||||
Console.WriteLine("The server at " + ServerIPOrHostName + " doesn't exit or cannot be found");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Resolve to an IPEndPoint
|
||||
IPHostEntry host = Dns.GetHostEntry( ipAddress );
|
||||
IPEndPoint ServerDenstination = new IPEndPoint(0, 0);
|
||||
foreach( IPAddress entry in host.AddressList ) {
|
||||
if ( entry.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork ) {
|
||||
ServerDenstination = new IPEndPoint( entry, Port );
|
||||
}
|
||||
}
|
||||
|
||||
// Return the initlized client object
|
||||
return new MistoxClient( UserName, ConnectionKey, ServerDenstination );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user