} //Server public void Start() { listener.Start(); listeningThread.Start(); protocolThread.Start(); ExecutionPhaseChanged?.Invoke(this, new ExecutionPhaseEventArgs(ExecutionPhase.Started)); } //Start
} //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
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