public bool Start() { try { _port.Open(); //the serial port is diffent with the tcp, Client connections cannot be distinguished,and serial port never trigger the accept event //so the serial port only one channel and one client //so it need manual trigger the accept ,let the supersocket framework to force create the connection session NewClientAccepted?.Invoke(this, _channelFactory(_port).Result); return(true); } catch (Exception e) { _logger.LogError(e, $"serial port: {_port.PortName} open fail!"); return(false); } }
protected virtual void OnNewClientAccepted(Socket socket, object state) { NewClientAccepted?.Invoke(this, socket, state); }
private void OnNewClientAccept(Socket socket) { NewClientAccepted?.Invoke(this, socket); }