static void Main(string[] args) { if (args.Length <= 0) { throw new Exception("No params Received"); } if (args[0] == "server") { SergServer server = new SergServer(); server.settings.debug = true; server.settings.maxClients = 5; server.settings.port = 4567; server.On("server-start", data => { if (server.IsServerRunning) { Console.WriteLine("Server started in " + data); } }); server.On("pong", (data) => { Console.WriteLine(data); Task.Run(() => { Thread.Sleep(200); server.Emit("ping", data); }); }); server.StartServer(); } else { SergClient client = new SergClient(); client.settings.debug = true; client.settings.ipConnect = "127.0.1.1"; client.settings.port = 4567; client.On("server-connect", data => { if (client.Connected) { Console.WriteLine("Client Connected"); client.Emit("pong", data); } }); client.On("ping", (data) => { Console.WriteLine(data); Task.Run(() => { Thread.Sleep(200); client.Emit("pong", data); }); }); client.ConnectToServer(); } Console.ReadKey(); }
/// <summary> /// On the specified name and callback. /// </summary> /// <param name="name">Name.</param> /// <param name="callback">Callback.</param> public void On(string name, SergIOCallback callback) => server.On(name, callback);