public void ConnectToServer() { if (!string.IsNullOrEmpty(this["Port"]) || !string.IsNullOrEmpty(this["IpAddress"])) return; var port = int.Parse(Port); var endPoint = new IPEndPoint(IPAddress.Parse(IpAddress), port); _transport = new ClientTransport(endPoint); _replicator = new Replicator.Replicator(Objects, _transport); _transport.ConnectionFailuer += s=> ConnectionError = s; _transport.Connected += () => { IsConnected = true; ConnectionError = string.Empty; }; Objects.Clear(); _transport.Connect(); }
public void ConnectToServer() { if (!string.IsNullOrEmpty(this["Port"]) || !string.IsNullOrEmpty(this["IpAddress"])) { return; } var port = int.Parse(Port); var endPoint = new IPEndPoint(IPAddress.Parse(IpAddress), port); _transport = new ClientTransport(endPoint); _replicator = new Replicator.Replicator(Objects, _transport); _transport.ConnectionFailuer += s => ConnectionError = s; _transport.Connected += () => { IsConnected = true; ConnectionError = string.Empty; }; Objects.Clear(); _transport.Connect(); }
public void StartServer() { if (!string.IsNullOrEmpty(this["Port"]) || string.IsNullOrEmpty(IpAddress)) return; var port = int.Parse(Port); Objects.Clear(); var endPoint = new IPEndPoint(IPAddress.Parse(IpAddress), port); _transport = new ServerTransport(endPoint); _replicator = new Replicator.Replicator(Objects, _transport); _transport.Receive += _transport.Retranslate; _transport.ClientConnected += ClientConnected; _transport.ClientDisconnected += s => ClientsCount--; _transport.StartFailed += s => { ConnectionError = s; IsStarted = false; }; _transport.Start(); IsStarted = true; }
public void StartServer() { if (!string.IsNullOrEmpty(this["Port"]) || string.IsNullOrEmpty(IpAddress)) { return; } var port = int.Parse(Port); Objects.Clear(); var endPoint = new IPEndPoint(IPAddress.Parse(IpAddress), port); _transport = new ServerTransport(endPoint); _replicator = new Replicator.Replicator(Objects, _transport); _transport.Receive += _transport.Retranslate; _transport.ClientConnected += ClientConnected; _transport.ClientDisconnected += s => ClientsCount--; _transport.StartFailed += s => { ConnectionError = s; IsStarted = false; }; _transport.Start(); IsStarted = true; }