Пример #1
0
        /// <summary>
        ///
        /// Start server loop that provide server pipe.
        /// </summary>
        /// <param name="guid">Id signed to connection.</param>
        /// <param name="pipeName">Name of the pipe that will be started.</param>
        /// <param name="securityLevel">Pipes security levels that will be applied to pipe.</param>
        /// <param name="getMessageHanler">Handler that generate brodcasting message for every connected client.</param>
        public static void ServerLoop(
            string guid,
            string pipeName,
            Security.SecurityLevel securityLevel,
            MessageHandeler getMessageHanler)
        {
            // Start loop.
            ServerAPI.ServerLoop <BroadcastTransmissionController>(
                guid,
                Handlers.DNS.BroadcastAsync,
                pipeName,
                PipeDirection.InOut,
                NamedPipeServerStream.MaxAllowedServerInstances,
                PipeTransmissionMode.Message,
                PipeOptions.Asynchronous | PipeOptions.WriteThrough,
                securityLevel,
                // Initialise broadcasting delegate.
                (BaseServerTransmissionController tc) =>
            {
                if (tc is BroadcastTransmissionController bstc)
                {
                    bstc.GetMessage = getMessageHanler;
                }
                else
                {
                    // Stop server
                    tc.SetStoped();

                    // Log error
                    Console.WriteLine("SERVER ERROR (BSS_TC 10): Created controler can't be casted to BroadcastingServerTransmissionController");
                }
            }
                );
        }
Пример #2
0
        /// <summary>
        /// Start server loop that provide server pipe.
        /// </summary>
        /// <param name="guid">Id signed to connection. Will generated authomaticly and returned to </param>
        /// <param name="pipeName">Name of the pipe that will be started.</param>
        /// <param name="securityLevel">Pipes security levels that will be applied to pipe.</param>
        /// <param name="getMessageHanler">Handler that generate brodcasting message for every connected client.</param>
        public static void ServerLoop(
            out string guid,
            string pipeName,
            Security.SecurityLevel securityLevel,
            MessageHandeler getMessageHanler)
        {
            // Generate GUID.
            guid = (System.Threading.Thread.CurrentThread.Name + "\\" + pipeName).GetHashCode().ToString();

            // Start loop.
            ServerLoop(guid, pipeName, securityLevel, getMessageHanler);
        }