Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

improved node data exchange

  • Loading branch information...
commit c7b4fd8299c4420231533b69ef5021e560a75ede 1 parent 8fb3818
@seuffert authored
View
4 XBSlink/xbs_node.cs
@@ -119,8 +119,8 @@ class xbs_node
private List<xbs_xbox> xbox_list;
private volatile int _last_ping_delay_ms;
- public int last_ping_delay_ms { get { return _last_ping_delay_ms; } private set { _last_ping_delay_ms = value; } }
- private DateTime lastPingTime = new DateTime(0);
+ public int last_ping_delay_ms { get { return _last_ping_delay_ms; } private set { _last_ping_delay_ms = value; } }
+ private DateTime lastPingTime = DateTime.MinValue;
public TimeSpan timeSinceLastPing { get { return (DateTime.Now - lastPingTime); } }
private DateTime lastPongTime = DateTime.Now;
public TimeSpan timeSinceLastPong { get { return (DateTime.Now - lastPongTime); } }
View
22 XBSlink/xbs_node_list.cs
@@ -43,6 +43,7 @@ class xbs_node_list
public const int MAX_PING_NO_RESPONSE_SECONDS = 30;
public const int MAX_ADD_NODE_TIMEOUT_SECONDS = 2;
public const int MAX_ASK_CLOUDHELPER_COUNT = 3;
+ public const int MIN_REFRESH_NODE_DELAY = 2;
private volatile bool run_ping_nodes_loop = true;
public volatile bool notify_on_new_node = true;
@@ -238,7 +239,7 @@ public void sendLogOff()
informNodesOnDelNode(local_node);
}
- public void pingAllnodes()
+ public void refreshAllNodes()
{
DateTime now = DateTime.Now;
List<xbs_node> del_list = new List<xbs_node>();
@@ -253,15 +254,20 @@ public void pingAllnodes()
time_since_last_ping = (int)n.timeSinceLastPing.TotalSeconds;
time_since_last_pong = (int)n.timeSinceLastPong.TotalSeconds;
if (time_since_last_ping > xbs_node_list.MIN_PING_DELAY_SECONDS || time_since_last_pong > xbs_node_list.MIN_PING_DELAY_SECONDS)
- {
n.sendPing();
- if (n.client_version == xbs_node.CLIENT_VERSION_UNKNOWN)
- n.sendGetClientVersion();
- if (n.nickname_received == false)
- n.sendGetNickname();
- }
+
if (time_since_last_pong > xbs_node_list.MAX_PING_NO_RESPONSE_SECONDS)
del_list.Add(n);
+ else
+ if ((DateTime.Now.Second % 2) == 0) // every 2 seconds check if all node data is available
+ {
+ if (n.client_version == xbs_node.CLIENT_VERSION_UNKNOWN)
+ n.sendGetClientVersion();
+ if (n.nickname_received == false)
+ n.sendGetNickname();
+ if (n.last_ping_delay_ms < 0 )
+ n.sendPing();
+ }
}
foreach (xbs_node n in del_list)
{
@@ -302,7 +308,7 @@ private void ping_nodes_thread()
while (run_ping_nodes_loop)
{
if(xbs_udp_listener.getInstance()!=null)
- pingAllnodes();
+ refreshAllNodes();
checkNodesInAddingList();
if (run_ping_nodes_loop)
Thread.Sleep(1000);
View
2  XBSlink/xbs_udp_listener.cs
@@ -369,6 +369,8 @@ public void dispatch_in_msg(ref xbs_udp_message udp_msg)
case xbs_node_message_type.KNOWNNODE:
xbs_node_message_knownnode msg_knownnode = new xbs_node_message_knownnode(udp_msg.data);
+
+ // only accept KNOWNNODE messages when not part of a cloud
if (!xbs_cloudlist.getInstance().part_of_cloud)
{
tmp_node = node_list.findNode(msg_knownnode.ip, msg_knownnode.port);
Please sign in to comment.
Something went wrong with that request. Please try again.