Exemplo n.º 1
0
        } //Server

        public void Start()
        {
            listener.Start();
            listeningThread.Start();
            protocolThread.Start();
            ExecutionPhaseChanged?.Invoke(this, new ExecutionPhaseEventArgs(ExecutionPhase.Started));
        } //Start
Exemplo n.º 2
0
        } //Start

        public void Stop()
        {
            RequestStop();
            using TcpClient stopper = new();
            stopper.Connect(localIpAddress, port);
            var          stream = stopper.GetStream();
            StreamWriter writer = new(stream);

            writer.AutoFlush = true;
            writer.WriteLine(DefinitionSet.StopIndicator);
            listener.Stop();
            ExecutionPhaseChanged?.Invoke(this, new ExecutionPhaseEventArgs(ExecutionPhase.Stopped));
        } //Stop
Exemplo n.º 3
0
        public Server(int port, IMPLEMENTATION implementor)
        {
            Debug.Assert(implementor != null);
            ExecutionPhaseChanged?.Invoke(this, new ExecutionPhaseEventArgs(ExecutionPhase.ReflectionStarted));
            var knownTypes = Utility.CollectKnownTypes(typeof(CONTRACT));

            serializer       = new(typeof(MethodSchema), knownTypes);
            methodDictionary = new MethodDictionary();
            CreateImplementingDynamicMethods(implementor);
            ExecutionPhaseChanged?.Invoke(this, new ExecutionPhaseEventArgs(ExecutionPhase.ReflectionComplete));
            this.implementor = implementor;
            this.port        = port;
            localIpAddress   = Dns.GetHostEntry(DefinitionSet.localHost).AddressList[0];
            listener         = new(localIpAddress, port);
            listeningThread  = new(ListenerThreadBody);
            protocolThread   = new(ProtocolThreadBody);
        } //Server