/// <summary> /// Private Constructor /// </summary> /// <param name="callback">Instance of the Callback Class</param> internal WcfSimulationClient(string[] extensionPaths, WcfSimulationCallback callback) { ClientId = -1; IsOpen = false; IsReady = false; Protocol = 0; this.extensionPaths = extensionPaths; this.callback = callback; this.callback.OnLevelChanged += callback_OnLevelChanged; this.callback.OnMasterChanged += callback_OnMasterChanged; this.callback.OnMessageReceived += callback_OnMessageReceived; this.callback.OnPlayerChanged += callback_OnPlayerChanged; this.callback.OnPlayerReset += callback_OnPlayerReset; this.callback.OnSimulationChanged += callback_OnSimulationChanged; this.callback.OnSimulationState += callback_OnSimulationState; this.callback.OnUserAdded += callback_OnUserAdded; this.callback.OnUserDropped += callback_OnUserDropped; this.callback.OnUserlistChanged += callback_OnUserlistChanged; this.callback.OnUsernameChanged += callback_OnUsernameChanged; for (byte i = 0; i < AntMe.Level.MAX_SLOTS; i++) { slots.Add(new Slot() { Id = i }); } }
/// <summary> /// Create a Client over Named Papes. /// </summary> /// <param name="pipeName">Pipe Name</param> /// <returns>Instance of the Client</returns> public static ISimulationClient CreateNamedPipe(string[] extensionPaths, string pipeName) { WcfSimulationCallback callback = new WcfSimulationCallback(); WcfSimulationClient client = new WcfSimulationClient(extensionPaths, callback); var factory = new DuplexChannelFactory <ISimulationService>( callback, new NetNamedPipeBinding(), new EndpointAddress("net.pipe://localhost/" + pipeName)); var channel = factory.CreateChannel(); client.Create(factory, channel); return(client); }
/// <summary> /// Create a Client over TCP. /// </summary> /// <param name="address">Target IP</param> /// <param name="port">Port</param> /// <returns>Instance of the Client</returns> public static ISimulationClient CreateTcp(string[] extensionPaths, IPAddress address, int port) { WcfSimulationCallback callback = new WcfSimulationCallback(); WcfSimulationClient client = new WcfSimulationClient(extensionPaths, callback); throw new NotImplementedException(); // TODO: var factory = new DuplexChannelFactory <ISimulationService>( callback, new NetTcpBinding(), new EndpointAddress("")); var channel = factory.CreateChannel(); client.Create(factory, channel); return(client); }