protected void connect0() { try { clearAdapters(); createAdapters(); addNetworkStatisticsAdapers(); updateAdapters(); closeSocket(); packetQueue.clear(); socketStatuses.clear(); datagramChannel = new UdpClient(); datagramChannel.Connect(serverAddress.getHost(), serverAddress.getPort()); startAdapters(); socketStatuses.push(EzySocketStatus.CONNECTING); sendHandshakeRequest(); Thread newThread = new Thread(() => { Thread.Sleep(3000); EzySocketStatus status = socketStatuses.last(); if (status == EzySocketStatus.CONNECTING) { socketStatuses.push(EzySocketStatus.CONNECT_FAILED); } reconnect(); }); newThread.Name = "udp-reconnect"; newThread.Start(); } catch (Exception e) { throw new EzyUdpConnectionException("udp can't connect to: " + serverAddress, e); } }
protected void connect0(int sleepTime) { clearAdapters(); createAdapters(); addNetworkStatisticsAdapers(); updateAdapters(); closeSocket(); packetQueue.clear(); socketEventQueue.clear(); socketStatuses.clear(); disconnectReason = (int)EzyDisconnectReason.UNKNOWN; connectionFailedReason = EzyConnectionFailedReason.UNKNOWN; Thread newThread = new Thread(() => connect1(sleepTime)); newThread.Name = "ezyfox-connection"; newThread.Start(); }