Пример #1
0
        public void OpenConnection(string ip)
        {
            socket = IO.Socket(String.IsNullOrEmpty(ip) ? CONNECTION_URL + ":" + CONNECTION_PORT : "http://" + ip);
            socket.On(Socket.EVENT_CONNECT, () =>
            {
                socket.Emit("connection", "AudioLightClient");
                OnConnectionOpened.Invoke(this, new EventArgs());
            });

            socket.On(Socket.EVENT_CONNECT_ERROR, () =>
            {
                OnFailedConnection.Invoke(this, new EventArgs());
            });
        }
Пример #2
0
 public void OpenConnection(string port)
 {
     try
     {
         serialPort.PortName = String.IsNullOrEmpty(port) ? PORT_NAME : port;
         serialPort.Open();
         OnConnectionOpened?.Invoke(this, new EventArgs());
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
         OnFailedConnection?.Invoke(this, new EventArgs());
     }
 }