Exemple #1
0
        /// <summary>
        ///     Destroys specified discovery instance.
        /// </summary>
        /// <param name="discovery"> <see cref="WakeDiscovery" /> instance to destroy. </param>
        public static void DestroyDiscovery(WakeDiscovery discovery)
        {
            if (!_discoveries.Contains(discovery))
            {
                Log(WakeError.DiscoveryNotExists);
                return;
            }

            discovery.Shutdown();
            RemoveSocket(discovery.Socket);
            _discoveries.Remove(discovery);
        }
Exemple #2
0
        /// <summary>
        ///     Create a discovery, that ready to broadcast or receive events.
        /// </summary>
        /// <param name="port"> Listen or broadcast port. </param>
        /// <param name="key"> Key parameter to specify game veresion. </param>
        /// <param name="version"> Major version of application. </param>
        /// <param name="subversion"> Minor version of application. </param>
        /// <returns></returns>
        public static WakeDiscovery CreateDiscovery(int port, int key, int version, int subversion)
        {
            if (!Initialized)
            {
                Log(WakeError.NotInitialized);
                return(null);
            }

            var discovery = new WakeDiscovery(port, key, version, subversion);

            if (!_discoveries.Contains(discovery))
            {
                _discoveries.Add(discovery);
                return(discovery);
            }

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