Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixes for cloud seperation

  • Loading branch information...
commit 8fb38184201eb6ee9f8e3bfa03770b9df81ca688 1 parent 5cf036a
@seuffert authored
View
2  XBSlink/CommandLine.cs
@@ -242,7 +242,7 @@ private void start_engine()
{
try
{
- cloudlist.JoinOrCreateCloud(option_cloudserver, option_cloudname, option_maxnodes.ToString(), option_password, node_list.local_node.ip_public, node_list.local_node.port_public, node_list.local_node.nickname, xbs_upnp.isPortReachable);
+ cloudlist.JoinOrCreateCloud(option_cloudserver, option_cloudname, option_maxnodes.ToString(), option_password, node_list.local_node.ip_public, node_list.local_node.port_public, node_list.local_node.nickname, xbs_upnp.isPortReachable, xbs_settings.xbslink_version);
}
catch (Exception e)
{
View
2  XBSlink/Form1.cs
@@ -1292,7 +1292,7 @@ private void button_CloudLeave_Click(object sender, EventArgs e)
private void join_cloud()
{
- bool ret = cloudlist.JoinOrCreateCloud(textBox_cloudlist.Text, textBox_CloudName.Text, textBox_CloudMaxNodes.Text, textBox_CloudPassword.Text, node_list.local_node.ip_public, node_list.local_node.port_public, node_list.local_node.nickname, xbs_upnp.isPortReachable);
+ bool ret = cloudlist.JoinOrCreateCloud(textBox_cloudlist.Text, textBox_CloudName.Text, textBox_CloudMaxNodes.Text, textBox_CloudPassword.Text, node_list.local_node.ip_public, node_list.local_node.port_public, node_list.local_node.nickname, xbs_upnp.isPortReachable, xbs_settings.xbslink_version);
if (ret)
{
toolTip2.Show("joined " + textBox_CloudName.Text, button_CloudJoin, 0, -20, 2000);
View
95 XBSlink/xbs_cloudlist.cs
@@ -227,29 +227,6 @@ public bool JoinOrCreateCloud(String url, String cloudname, String max_nodes, St
xbs_messages.addDebugMessage(" x cloud node UUID: " + uuid, xbs_message_sender.CLOUDLIST);
#endif
cloudlist_url = url;
- if (result_rows.Length >= 2)
- {
- for (int row_num = 1; row_num < result_rows.Length; row_num++)
- {
- IPAddress ip;
- int port;
- try
- {
- NameValueCollection node_data = HttpUtility.ParseQueryString(result_rows[row_num]);
- ip = IPAddress.Parse(node_data[xbs_cloudlist_getparameters.NODEIP]);
- port = int.Parse(node_data[xbs_cloudlist_getparameters.NODEPORT]);
- }
- catch (Exception)
- {
- xbs_messages.addInfoMessage("!! Error getting node contact from cloudlist server: " + result_rows[1], xbs_message_sender.CLOUDLIST, xbs_message_type.ERROR);
- return false;
- }
- xbs_node_message_announce msg = new xbs_node_message_announce(ip, port);
- msg.addOption(xbs_node_message_announce.OPTION_CLOUDNAME, cloudname);
- if (xbs_udp_listener.getInstance()!=null)
- xbs_udp_listener.getInstance().send_xbs_node_message(msg);
- }
- }
startUpdateThread();
return true;
}
@@ -306,14 +283,8 @@ private void startUpdateThread()
private void update_cloudlist_threadstart()
{
- DateTime last_update = DateTime.Now;
- List<String> get_params = new List<String>();
+ DateTime last_update = DateTime.MinValue;
TimeSpan ts = new TimeSpan();
- get_params.Add(xbs_cloudlist_getparameters.CMD + "=" + xbs_cloudlist_command.CMD_UPDATE);
- get_params.Add(xbs_cloudlist_getparameters.CLOUDNAME + "=" + HttpUtility.UrlEncode(current_cloudname));
- get_params.Add(xbs_cloudlist_getparameters.UUID + "=" + HttpUtility.UrlEncode(uuid));
- string result = null;
- String url = cloudlist_url + "?" + String.Join("&", get_params.ToArray());
xbs_messages.addInfoMessage(" x started cloudlist updater", xbs_message_sender.CLOUDLIST);
#if !DEBUG
try
@@ -324,32 +295,7 @@ private void update_cloudlist_threadstart()
ts = DateTime.Now - last_update;
if (ts.TotalSeconds > xbs_cloudlist.UPDATE_INTERVAL_SECONDS)
{
- url = cloudlist_url + "?" + String.Join("&", get_params.ToArray());
- xbs_messages.addDebugMessage(" x update of cloud status: " + url, xbs_message_sender.CLOUDLIST);
- WebClient client = new WebClient();
- client.Proxy = null;
- try
- {
- result = client.DownloadString(url);
- }
- catch (WebException wex)
- {
- xbs_messages.addInfoMessage("!! could not updated status on cloudlist server. Error: " + wex.Message, xbs_message_sender.CLOUDLIST, xbs_message_type.ERROR);
- }
- if (result==null || !(result is String))
- {
-
- }
- else if (!result.StartsWith(xbs_cloudlist_returncode.RETURN_CODE_OK))
- xbs_messages.addInfoMessage("!! cloudlist server returned error on update", xbs_message_sender.CLOUDLIST, xbs_message_type.ERROR);
- else
- {
- String[] result_rows = result.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
- xbs_messages.addDebugMessage(" x cloud list update returned rows: " + result_rows.Length, xbs_message_sender.CLOUDLIST);
- if (result_rows.Length >= 2)
- for (int row_num = 1; row_num < result_rows.Length; row_num++)
- updateNodeInCloud(result_rows[row_num]);
- }
+ sendUpdateToCloudlistserver();
last_update = DateTime.Now;
}
Thread.Sleep(1000);
@@ -363,6 +309,43 @@ private void update_cloudlist_threadstart()
#endif
}
+ public void sendUpdateToCloudlistserver()
+ {
+ List<String> get_params = new List<String>();
+ get_params.Add(xbs_cloudlist_getparameters.CMD + "=" + xbs_cloudlist_command.CMD_UPDATE);
+ get_params.Add(xbs_cloudlist_getparameters.CLOUDNAME + "=" + HttpUtility.UrlEncode(current_cloudname));
+ get_params.Add(xbs_cloudlist_getparameters.UUID + "=" + HttpUtility.UrlEncode(uuid));
+ string result = null;
+ String url = cloudlist_url + "?" + String.Join("&", get_params.ToArray());
+ url = cloudlist_url + "?" + String.Join("&", get_params.ToArray());
+ xbs_messages.addDebugMessage(" x update of cloud status: " + url, xbs_message_sender.CLOUDLIST);
+ WebClient client = new WebClient();
+ client.Proxy = null;
+ try
+ {
+ result = client.DownloadString(url);
+ }
+ catch (WebException wex)
+ {
+ xbs_messages.addInfoMessage("!! could not updated status on cloudlist server. Error: " + wex.Message, xbs_message_sender.CLOUDLIST, xbs_message_type.ERROR);
+ }
+ if (result == null || !(result is String))
+ {
+
+ }
+ else if (!result.StartsWith(xbs_cloudlist_returncode.RETURN_CODE_OK))
+ xbs_messages.addInfoMessage("!! cloudlist server returned error on update", xbs_message_sender.CLOUDLIST, xbs_message_type.ERROR);
+ else
+ {
+ String[] result_rows = result.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
+ xbs_messages.addDebugMessage(" x cloud list update returned rows: " + result_rows.Length, xbs_message_sender.CLOUDLIST);
+ if (result_rows.Length >= 2)
+ for (int row_num = 1; row_num < result_rows.Length; row_num++)
+ updateNodeInCloud(result_rows[row_num]);
+ }
+
+ }
+
public void updateNodeInCloud( String row_data )
{
IPAddress ip;
View
9 XBSlink/xbs_udp_listener.cs
@@ -380,11 +380,12 @@ public void dispatch_in_msg(ref xbs_udp_message udp_msg)
#endif
node_list.tryAddingNode(tmp_node, xbs_cloudlist.getInstance().current_cloudname);
}
- }
#if DEBUG
- else
- xbs_messages.addDebugMessage(" * already in contact with node: " + tmp_node, xbs_message_sender.UDP_LISTENER);
+ else
+ xbs_messages.addDebugMessage(" * already in contact with node: " + tmp_node, xbs_message_sender.UDP_LISTENER);
#endif
+ }
+
break;
case xbs_node_message_type.ADDNODE:
@@ -488,7 +489,7 @@ public void dispatch_in_msg(ref xbs_udp_message udp_msg)
case xbs_node_message_type.FROM_CLOUDHELPER_CONTACTNODE:
xbs_node_message_fromCloudHelper_ContactNode msg_fromCloudContactNode = new xbs_node_message_fromCloudHelper_ContactNode(udp_msg.data);
tmp_node = new xbs_node(msg_fromCloudContactNode.ip, msg_fromCloudContactNode.port);
- tmp_node.sendAddNodeMessage(node_list.local_node);
+ node_list.tryAddingNode(tmp_node, xbs_cloudlist.getInstance().current_cloudname);
break;
}
Please sign in to comment.
Something went wrong with that request. Please try again.