static void Main(string[] args) { GClient = new ASocket("localhost", AisProtocolType.App); GMutex = new Mutex(); String aInput = String.Empty; // Register event handlers GClient.ConnectedEvent += OnConnected; GClient.DisconnectedEvent += OnDisconnected; GClient.SocketErrorEvent += OnSocketError; GClient.ResponseEvent += OnResponse; while (true) { try { GMutex.WaitOne(); Console.Write("> "); GMutex.ReleaseMutex(); aInput = Console.ReadLine().Trim(); if (aInput == "connect") { DoConnect(); } else if (aInput == "disconnect") { DoDisconnect(); } else if (aInput == "send") { DoSend(); } else if (aInput == "sendlarge") { DoSendLarge(); } else if (aInput == "quit") { DoDisconnect(); break; } else if (aInput == "sendrepeat") { DoSendRepeat(); } else if (aInput.Length > 0) { Console.WriteLine("Unknown command"); Console.WriteLine("Try connect, disconnect, send, sendlarge, sendrepeate, or quit"); } } catch (Exception e) { Console.Error.WriteLine(e.Message); } } }
protected abstract void Execute(ASocket socket, object[] parameter);