Exemplo n.º 1
0
 public void BindListener()
 {
     Listner.Tell(new ChannelRegistration(
                      x => _interestCallReceiver.Ref.Tell((int)x),
                      x => _interestCallReceiver.Ref.Tell(-(int)x)));
     _bindCommander.ExpectMsg <Tcp.Bound>();
 }
Exemplo n.º 2
0
    /// <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());
    }
Exemplo n.º 3
0
        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();
            }
        }
Exemplo n.º 4
0
 public void Terminate()
 {
     Run = false;
     Listner.Stop();
     Leaving();
 }
Exemplo n.º 5
0
 public void AddListner(Listner listner)
 {
     listners.Add(listner);
 }
Exemplo n.º 6
0
 public void StartGame()
 {
     Listner.Stop();
     Participants.ForEach(p => p.Start());
 }