public void Start() { Client = new USocketClient(Hostname, Port) { Persistent = true, Timeout = 1000 }; foreach (Delegate del in _OnMessageReceived.GetInvocationList()) { Client.OnMessageReceived += new USocketClient.MessageHandler((MessageHandler)del); } Configurations.Instance.SetAndAddCallback("ConnectionSocket_IP", Hostname, v => Client.Host = v); Configurations.Instance.SetAndAddCallback("ConnectionSocket_Port", Port, v => Client.Port = v); Configurations.Instance.SetAndAddCallback("ConnectionSocket_Connect", false, v => { if (v) { Client.Connect(); } else { Client.Close(); } }); }
private void OnConnectClick(object sender, RoutedEventArgs e) { btnConnect.Visibility = Visibility.Collapsed; client = new USocketClient(tbIP.Text, 12345); client.Persistent = true; client.MessageReceived += OnMessage; client.Disconnected += OnDisconnect; client.Connect(); btnDisonnect.Visibility = Visibility.Visible; }
protected void ConnectionReceived(USocketServer server, USocketClient client) { Client?.Close(); Client = client; Client.OnMessageReceived += MessageReceived; Client.BeginRead(); SendControl(); SendLog(); SendStatus(); }