Ejemplo n.º 1
0
 /**
  * Initialize method which will create the socket
  */
 private void Initialize(string ip, int port)
 {
     IsInitialized = false;
     try
     {
         ReadManager.Initialize(ReadHandlers);
         WriteManager.Initialize(WriteHandlers);
         InputManager.Initialize(InputInfos);
         Socket.Connect(ip, port);
         Stream        = Socket.GetStream();
         IsInitialized = true;
     }
     catch (Exception e)
     {
         Console.Out.WriteLineAsync(e.ToString());
     }
 }
Ejemplo n.º 2
0
        /**
         * Initiliaze listener
         */
        private bool Initialize(int port = DefaultServerPort)
        {
            IsInitialized = false;
            try
            {
                ReadManager.Initialize(ReadHandlers);
                WriteManager.Initialize(WriteHandlers);

                Listener = new TcpListener(IPAddress.Any, port);

                ClientList = new Dictionary <int, Client>();
                LobbyList  = new List <Lobby>();

                Listener.Start();
                IsInitialized = true;
                return(true);
            }
            catch (Exception e)
            {
                Console.Out.WriteLineAsync(e.ToString());
                return(false);
            }
        }