本文整理汇总了C#中GonzoNet.NetworkClient.Connect方法的典型用法代码示例。如果您正苦于以下问题:C# NetworkClient.Connect方法的具体用法?C# NetworkClient.Connect怎么用?C# NetworkClient.Connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GonzoNet.NetworkClient
的用法示例。
在下文中一共展示了NetworkClient.Connect方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VMClientDriver
public VMClientDriver(string hostName, int port, OnStateChangeDelegate callback)
{
Commands = new Queue<VMNetCommandBodyAbstract>();
Client = new NetworkClient(hostName, port, EncryptionMode.NoEncryption, true);
Client.OnConnected += Client_OnConnected;
Client.OnDisconnect += Client_OnDisconnect;
OnStateChange += callback;
Client.Connect(null);
TickBuffer = new Queue<VMNetTick>();
}
示例2: VMClientDriver
private VM VMHook; //should probably always backreference the VM anyways, but just used by disconnect
#endregion Fields
#region Constructors
public VMClientDriver(string hostName, int port, OnStateChangeDelegate callback)
{
Commands = new Queue<VMNetCommandBodyAbstract>();
Client = new NetworkClient(hostName, port, EncryptionMode.NoEncryption, true);
Client.OnConnected += Client_OnConnected;
Client.OnDisconnect += Client_OnDisconnect;
OnStateChange += callback;
Client.Connect(null);
GlobalLink = null; //transactions only performed by server. transaction results
//are passed back to the clients as commands (for the primitive, at least)
TickBuffer = new Queue<VMNetTick>();
}
示例3: Form1
public Form1()
{
InitializeComponent();
bool FoundConfig = ConfigurationManager.LoadCityConfig();
Logger.Initialize("Log.txt");
Logger.WarnEnabled = true;
Logger.DebugEnabled = true;
GonzoNet.Logger.OnMessageLogged += new GonzoNet.MessageLoggedDelegate(Logger_OnMessageLogged);
CityDataModel.Logger.OnMessageLogged += new CityDataModel.MessageLoggedDelegate(Logger_OnMessageLogged);
ProtocolAbstractionLibraryD.Logger.OnMessageLogged += new ProtocolAbstractionLibraryD.MessageLoggedDelegate(Logger_OnMessageLogged);
if (!FoundConfig)
{
Logger.LogWarning("Couldn't find a ServerConfig.ini file!");
//TODO: This doesn't work...
Application.Exit();
}
//This has to happen for the static constructor to be called...
NetworkFacade m_NetworkFacade = new NetworkFacade();
var dbConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["MAIN_DB"];
DataAccess.ConnectionString = dbConnectionString.ConnectionString;
m_Listener = new Listener();
//m_Listener.OnReceiveEvent += new OnReceiveDelegate(m_Listener_OnReceiveEvent);
m_LoginClient = new NetworkClient("127.0.0.1", 2108);
m_LoginClient.OnNetworkError += new NetworkErrorDelegate(m_LoginClient_OnNetworkError);
m_LoginClient.OnConnected += new OnConnectedDelegate(m_LoginClient_OnConnected);
m_LoginClient.Connect(null);
//Send a pulse to the LoginServer every second.
m_PulseTimer = new System.Timers.Timer(1000);
m_PulseTimer.AutoReset = true;
m_PulseTimer.Elapsed += new ElapsedEventHandler(m_PulseTimer_Elapsed);
m_PulseTimer.Start();
m_Listener.Initialize(Settings.BINDING);
}
示例4: Main
static void Main(string[] args)
{
bool FoundConfig = ConfigurationManager.LoadCityConfig();
Logger.Initialize("Log.txt");
Logger.WarnEnabled = true;
Logger.DebugEnabled = true;
GonzoNet.Logger.OnMessageLogged += new GonzoNet.MessageLoggedDelegate(Logger_OnMessageLogged);
CityDataModel.Logger.OnMessageLogged += new CityDataModel.MessageLoggedDelegate(Logger_OnMessageLogged);
ProtocolAbstractionLibraryD.Logger.OnMessageLogged += new ProtocolAbstractionLibraryD.MessageLoggedDelegate(Logger_OnMessageLogged);
if (!FoundConfig)
{
Console.WriteLine("Couldn't find a ServerConfig.ini file!");
Console.ReadLine();
Environment.Exit(0);
}
//This has to happen for the static constructor to be called...
NetworkFacade m_NetworkFacade = new NetworkFacade();
var dbConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["MAIN_DB"];
DataAccess.ConnectionString = dbConnectionString.ConnectionString;
NetworkFacade.NetworkListener = new Listener(EncryptionMode.AESCrypto);
//Remove a player from the current session when it disconnects.
NetworkFacade.NetworkListener.OnDisconnected += new OnDisconnectedDelegate(NetworkFacade.CurrentSession.RemovePlayer);
m_LoginClient = new NetworkClient("127.0.0.1", 2108, EncryptionMode.AESCrypto, true);
m_LoginClient.OnNetworkError += new NetworkErrorDelegate(m_LoginClient_OnNetworkError);
m_LoginClient.OnConnected += new OnConnectedDelegate(m_LoginClient_OnConnected);
m_LoginClient.Connect(null);
//Adds all houses from DB to the current session.
using(DataAccess db = DataAccess.Get())
{
IQueryable<Character> Chars = db.Characters.GetAllCharsWithHouses();
var CharsWithHouses = Chars.Where(x => x.HouseHouse != null);
foreach(Character Char in CharsWithHouses)
NetworkFacade.CurrentSession.AddHouse(Char, Char.HouseHouse);
}
NetworkFacade.NetworkListener.Initialize(Settings.BINDING);
m_NancyHost = new NancyHost(new Uri("http://173.248.136.133:8888/city/"));
m_NancyHost.Start();
try
{
NetworkFacade.CurrentTerrain.Initialize("East Jerome");
NetworkFacade.CurrentTerrain.LoadContent();
NetworkFacade.CurrentTerrain.GenerateCityMesh();
}
catch(Exception e)
{
Console.WriteLine("Couldn't load elevation data!");
Console.WriteLine(e.ToString());
Console.ReadLine();
Environment.Exit(0);
}
m_VM = new VM.VM();
m_VM.Init();
while (true)
{
m_VM.Update();
Thread.Sleep(1000);
}
}
示例5: Form1
public Form1()
{
InitializeComponent();
bool FoundConfig = ConfigurationManager.LoadCityConfig();
Logger.Initialize("Log.txt");
Logger.WarnEnabled = true;
Logger.DebugEnabled = true;
GonzoNet.Logger.OnMessageLogged += new MessageLoggedDelegate(Logger_OnMessageLogged);
if (!FoundConfig)
{
Logger.LogWarning("Couldn't find a ServerConfig.ini file!");
//TODO: This doesn't work...
Application.Exit();
}
//This has to happen for the static constructor to be called...
NetworkFacade m_NetworkFacade = new NetworkFacade();
var dbConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["MAIN_DB"];
DataAccess.ConnectionString = dbConnectionString.ConnectionString;
/** TODO: Test the database **/
using (var db = DataAccess.Get())
{
var testAccount = db.Accounts.GetByUsername("root");
if (testAccount == null)
{
db.Accounts.Create(new Account
{
AccountName = "root",
Password = "root"
});
}
}
m_Listener = new Listener();
//m_Listener.OnReceiveEvent += new OnReceiveDelegate(m_Listener_OnReceiveEvent);
m_LoginClient = new NetworkClient("127.0.0.1", 2108);
m_LoginClient.OnNetworkError += new NetworkErrorDelegate(m_LoginClient_OnNetworkError);
m_LoginClient.OnConnected += new OnConnectedDelegate(m_LoginClient_OnConnected);
m_LoginClient.Connect(null);
//Send a pulse to the LoginServer every second.
m_PulseTimer = new System.Timers.Timer(1000);
m_PulseTimer.AutoReset = true;
m_PulseTimer.Elapsed += new ElapsedEventHandler(m_PulseTimer_Elapsed);
m_PulseTimer.Start();
m_Listener.Initialize(Settings.BINDING);
}
示例6: Reconnect
/// <summary>
/// Reconnects to a CityServer.
/// </summary>
public void Reconnect(ref NetworkClient Client, CityInfo SelectedCity, LoginArgsContainer LoginArgs)
{
Client.Disconnect();
if (LoginArgs.Enc == null)
{
System.Diagnostics.Debug.WriteLine("LoginArgs.Enc was null!");
LoginArgs.Enc = new GonzoNet.Encryption.AESEncryptor(Convert.ToBase64String(PlayerAccount.Hash));
}
else if (LoginArgs.Username == null || LoginArgs.Password == null)
{
System.Diagnostics.Debug.WriteLine("LoginArgs.Username or LoginArgs.Password was null!");
LoginArgs.Username = PlayerAccount.Username;
LoginArgs.Password = Convert.ToBase64String(PlayerAccount.Hash);
}
Client.Connect(LoginArgs);
}