Exemple #1
0
        /// <summary>
        /// </summary>
        /// <param name="address">
        /// </param>
        /// <param name="port">
        /// </param>
        /// <param name="received">
        /// </param>
        public static void StartServer(IPAddress address, int port, OnReceivedMessageFromClient received)
        {
            if (isServer == true)
            {
                return;
            }

            if (isServer == false)
            {
                Console.WriteLine("Already initialized as Server");
            }

            ReceivedMessageFromClient += received;
            server                  = new ZoneComServer(address, port);
            server.OnConnect       += ServerToClientConnected;
            server.OnDisconnect    += ServerToClientDisconnected;
            server.MessageReceived += ServerMessageReceived;
            try
            {
                server.StartServer();
            }
            catch (Exception)
            {
                ServerToClientDisconnected(null, null);
                return;
            }

            isServer = true;
        }
        /// <summary>
        /// </summary>
        /// <param name="address">
        /// </param>
        /// <param name="port">
        /// </param>
        /// <param name="received">
        /// </param>
        public static void StartServer(IPAddress address, int port, OnReceivedMessageFromClient received)
        {
            if (isServer == true)
            {
                return;
            }

            if (isServer == false)
            {
                Console.WriteLine("Already initialized as Server");
            }

            ReceivedMessageFromClient += received;
            server = new ZoneComServer(address, port);
            server.OnConnect += ServerToClientConnected;
            server.OnDisconnect += ServerToClientDisconnected;
            server.MessageReceived += server_MessageReceived;
            try
            {
                server.StartServer();
            }
            catch (Exception)
            {
                ServerToClientDisconnected();
                return;
            }

            isServer = true;
        }