public IPlayer(String dns, int port) { NetAppConfiguration myConfig = new NetAppConfiguration("MMO Mahjong"); m_log = new NetLog(); Init(); m_client = new NetClient(myConfig, m_log); m_client.Connect(dns, port); m_client.StatusChanged += new EventHandler<NetStatusEventArgs>(StatusChanged); Application.Idle += new EventHandler(ApplicationLoop); }
public Program() { NetAppConfiguration myConfig = new NetAppConfiguration("MMO Mahjong", 14242); NetLog log = new NetLog(); NetClient Client = new NetClient(myConfig, log); Client.Connect("localhost", 14242); // takes IP number or hostnameHow to detect connects/disconnects Client.StatusChanged += new EventHandler<NetStatusEventArgs>(StatusChanged);// to track connect/disconnect etc bool keepGoing = true; while (keepGoing) { Client.Heartbeat(); NetMessage msg; while ((msg = Client.ReadMessage()) != null) { string str = msg.ReadString(); // <- for example System.Console.WriteLine("You got a packet containing: " + str); Thread.Sleep(1); } } }
public void ClientClicked() { this.Window.Title = "Trying To Connect...."; //Since this is a client we dont have to specify a port here nac = new NetAppConfiguration("ZombieSim"); Log = new NetLog(); //Im Using this to show how to log files, So we pick that we want //to ignore nothing, Change this depending on what your //wanting to log for various debugging. Log.IgnoreTypes = NetLogEntryTypes.None; //Specify if you want to enable output to a file which we do. Log.IsOutputToFileEnabled = true; //If we output to a file we have to pick a filename to output it to. Log.OutputFileName = "Client.html"; //We Initiate the client here, it has not connected to the server yet. client = new NetClient(nac, Log); //We Want to Log Events that are fired from the client client.StatusChanged += new EventHandler<NetStatusEventArgs>(client_StatusChanged); //Finally we connect to the server, Specify the IP Address and //port if your wanting to connect to xxx.xxx.xxx.xxx //we would change this line to "192.168.1.1",12345 client.Connect("192.168.0.200", 12345); }