Exemplo n.º 1
0
        /// <summary>
        ///     Destroys specified client.
        /// </summary>
        /// <returns><c>true</c>, if client was destroyed, <c>false</c> otherwise.</returns>
        /// <param name="client"><see cref="WakeClient" /> object to destroy. </param>
        public static void DestroyClient(WakeClient client)
        {
            if (!_clients.Contains(client))
            {
                Log(WakeError.ClientNotExists);
                return;
            }

            client.Disconnect();
            RemoveSocket(client.Socket);
            _clients.Remove(client);
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Create a client that is ready to connect with a server.
        /// </summary>
        /// <returns> The <see cref="WakeClient" /> instance.</returns>
        public static WakeClient CreateClient()
        {
            if (!Initialized)
            {
                Log(WakeError.NotInitialized);
                return(null);
            }

            var client = new WakeClient();

            // If we were successful in creating our client and it is unique
            if (!_clients.Contains(client))
            {
                _clients.Add(client);

                return(client);
            }

            RemoveSocket(client.Socket);
            return(null);
        }