public void Start() { StartServerParameter sp = new StartServerParameter(); sp.protocolVersion = new Nettention.Proud.Guid(Common.Vars.g_ProtocolVersion); sp.tcpPorts = new IntArray(); sp.tcpPorts.Add(Common.Vars.g_serverPort); sp.serverAddrAtClient = "175.204.115.46"; sp.localNicAddr = "175.204.115.46"; sp.SetExternalNetWorkerThreadPool(netWorkerThreadPool); sp.SetExternalUserWorkerThreadPool(userWorkerThreadPool); m_netServer.Start(sp); }
public void Start() { //fill server startup parameters StartServerParameter sp = new StartServerParameter(); sp.protocolVersion = new Nettention.Proud.Guid(SngCommon.Vars.g_sngProtocolVersion); sp.tcpPorts = new IntArray(); sp.tcpPorts.Add(SngCommon.Vars.g_serverPort); // must be same to the port number at client sp.serverAddrAtClient = "192.168.219.100"; sp.localNicAddr = "192.168.219.100"; sp.SetExternalNetWorkerThreadPool(netWorkerThreadPool); sp.SetExternalUserWorkerThreadPool(userWorkerThreadPool); // let's start! m_netServer.Start(sp); }
static void Main(string[] args) { // Network server instance. NetServer srv = new NetServer(); // set a routine which is executed when a client is joining. // clientInfo has the client info including its HostID. srv.ClientJoinHandler = (clientInfo) => { Console.WriteLine("#clients: {0}", srv.GetClientHostIDs().Length); Console.WriteLine("Client {0} connected.\n", clientInfo.hostID); }; // set a routine for client leave event. srv.ClientLeaveHandler = (clientInfo, errorInfo, comment) => { Console.WriteLine("Client {0} disconnected.\n", clientInfo.hostID); }; var p1 = new StartServerParameter(); p1.protocolVersion = new Nettention.Proud.Guid(Vars.m_Version); // This must be the same to the client. p1.tcpPorts.Add(Vars.m_serverPort); // TCP listening endpoint srv.ReceiveUserMessageHandler = (sender, rmiContext, payload) => { Console.Write(payload.data.Length); Console.Write(System.Text.Encoding.Default.GetString(payload.data)); }; try { /* Starts the server. * This function throws an exception on failure. * Note: As we specify nothing for threading model, * RMI function by message receive and event callbacks are * called in a separate thread pool. * You can change the thread model. Check out the help pages for details. */ srv.Start(p1); } catch (Exception e) { Console.Write("Server start failed: {0}\n", e.ToString()); return; } Console.Write("Server started. Enterable commands:\n"); Console.Write("q: Quit.\n"); string userInput; while (true) { // get user input userInput = Console.ReadLine(); if (userInput == "q") { // exit program. break; } else if (userInput == "m") { } } srv.Stop(); }