void IApplication.OnInit(string[] args) { server = FNet.CreateTcpServer(new TcpServerConfig() { KeepAlive = 5000, SendImmediately = true, }); server.OnClientConnected += conn => { Console.WriteLine($"connected: {conn.ConnectionId} {conn.IP}:{conn.Port}"); client++; }; server.OnClientDisconnected += (conn, type) => { Console.WriteLine($"disconnected: {conn.ConnectionId} {type}"); }; server.OnClientReceive += (conn, data) => { var msg = Encoding.UTF8.GetString(data); Console.WriteLine($"receive: {conn.ConnectionId} {msg}"); var send = Encoding.UTF8.GetBytes("pong"); conn.Send(send); }; server.OnServerClosed += server => { Console.WriteLine("Server closed."); }; server.BeginAccept(); }