public void BindListener() { Listner.Tell(new ChannelRegistration( x => _interestCallReceiver.Ref.Tell((int)x), x => _interestCallReceiver.Ref.Tell(-(int)x))); _bindCommander.ExpectMsg <Tcp.Bound>(); }
/// <summary> /// Добавить промежуточный метод. Привязать метод к эвенту /// </summary> public int SubcribeEvent(Action <T> method, EventPriority priority = EventPriority.Normal) { Listner <T> listner = new Listner <T>(method, priority); listners.Add(listner); listners = listners.OrderBy(x => x.GetPriority()).ToList(); return(listner.GetId()); }
static void Listen(string prefix, string secondprefix) { Console.WriteLine(prefix + "Start listening connections."); Listner.Listen(1); while (true) { #if CONSOLE_REDIRECT sw.Close(); sw = new StreamWriter(new FileStream("dump.txt", FileMode.Append, FileAccess.Write)); Console.SetOut(sw); #endif Console.Write(prefix + secondprefix + "Awaiting client..."); Socket handler = Listner.Accept(); Console.Write(" {0} connected.\n" + prefix + secondprefix + "Receiving data...", handler.LocalEndPoint); string data = null; byte[] bytes = new byte[67108864]; int recievedLength = handler.Receive(bytes); data = Encoding.UTF8.GetString(bytes, 0, recievedLength); Console.WriteLine(" data recieved."); byte[] msg; try { msg = HandleData(data, prefix + secondprefix + " ", " "); } catch (Exception ex) { msg = Encoding.UTF8.GetBytes("HTTP/1.1 500 Internal Server Error\nContent-Type: text/html; cahrset=utf-8;\n\n" + FAVICON + "<h1 align=\"center\">500 Internal Server Error</h1>" + COPYRIGHT); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(prefix + ex.ToString()); Console.ForegroundColor = ConsoleColor.White; } Console.WriteLine(prefix + secondprefix + "Sending data..."); handler.Send(msg); Console.WriteLine(" done.\n" + prefix + secondprefix + "Shutting down connection."); handler.Shutdown(SocketShutdown.Both); handler.Close(); } }
public void Terminate() { Run = false; Listner.Stop(); Leaving(); }
public void AddListner(Listner listner) { listners.Add(listner); }
public void StartGame() { Listner.Stop(); Participants.ForEach(p => p.Start()); }