Переглянути джерело

2009-08-26 Atsushi Enomoto <[email protected]>

	* PeerNode.cs : use ulong as same as Welcome message value.

	* PeerDuplexChannel.cs : in the Welcome response, return the NodeId
	  of the receiver, not the requestor. It resolved the issue that
	  .NET client didn't send further messages to mono server.


svn path=/trunk/mcs/; revision=140693
Atsushi Eno 16 роки тому
батько
коміт
48420dfd94

+ 6 - 0
mcs/class/System.ServiceModel/System.ServiceModel.Channels/ChangeLog

@@ -1,3 +1,9 @@
+2009-08-26  Atsushi Enomoto  <[email protected]>
+
+	* PeerDuplexChannel.cs : in the Welcome response, return the NodeId
+	  of the receiver, not the requestor. It resolved the issue that
+	  .NET client didn't send further messages to mono server.
+
 2009-08-26  Atsushi Enomoto  <[email protected]>
 
 	* PeerDuplexChannel.cs : remove some comment on [MC-PRCH] behavior.

+ 10 - 2
mcs/class/System.ServiceModel/System.ServiceModel.Channels/PeerDuplexChannel.cs

@@ -69,12 +69,14 @@ namespace System.ServiceModel.Channels
 			public RemotePeerStatus Status { get; set; }
 			public LocalPeerReceiver Instance { get; set; }
 			public IPeerConnectorClient Channel { get; set; }
+			public ulong NodeId { get; set; }
 		}
 
 		class LocalPeerReceiver : IPeerConnectorContract
 		{
 			List<PeerNodeAddress> connections = new List<PeerNodeAddress> ();
 			AutoResetEvent connect_handle = new AutoResetEvent (false);
+			public event Action<WelcomeInfo> WelcomeReceived;
 
 			public LocalPeerReceiver (PeerDuplexChannel owner)
 			{
@@ -93,7 +95,7 @@ namespace System.ServiceModel.Channels
 				// FIXME: check and reject if inappropriate. For example, maximum connection exceeded.
 				using (var octx = new OperationContextScope ((IContextChannel) ch)) {
 					OperationContext.Current.OutgoingMessageHeaders.To = new Uri (Constants.WsaAnonymousUri);
-					ch.Welcome (new WelcomeInfo () { NodeId = connect.NodeId });
+					ch.Welcome (new WelcomeInfo () { NodeId = owner.node.NodeId });
 				}
 			}
 
@@ -115,6 +117,8 @@ Console.WriteLine ("##### Waiting for Welcome or Reject ...");
 			public void Welcome (WelcomeInfo welcome)
 			{
 Console.WriteLine ("##### Welcome message received");
+				if (WelcomeReceived != null)
+					WelcomeReceived (welcome);
 				connect_handle.Set ();
 			}
 
@@ -195,6 +199,10 @@ Console.WriteLine ("##### non-connector message received: " + msg.Headers.Action
 		IPeerConnectorClient CreateInnerClient (RemotePeerConnection conn)
 		{
 			conn.Instance = new LocalPeerReceiver (this);
+			conn.Instance.WelcomeReceived += delegate (WelcomeInfo welcome) {
+				conn.NodeId = welcome.NodeId;
+				// FIXME: handle referrals
+				};
 
 			// FIXME: pass more setup parameters
 			if (channel_factory == null) {
@@ -338,7 +346,7 @@ Console.WriteLine ("##### non-connector message received: " + msg.Headers.Action
 
 			listener_host.Open (timeout - (DateTime.Now - start));
 
-			var nid = new Random ().Next (0, int.MaxValue);
+			var nid = (ulong) new Random ().Next (0, int.MaxValue);
 			var ea = new EndpointAddress (uri);
 			var pna = new PeerNodeAddress (ea, new ReadOnlyCollection<IPAddress> (Dns.GetHostEntry (name).AddressList));
 			local_node_address = pna;

+ 4 - 0
mcs/class/System.ServiceModel/System.ServiceModel/ChangeLog

@@ -1,3 +1,7 @@
+2009-08-26  Atsushi Enomoto  <[email protected]>
+
+	* PeerNode.cs : use ulong as same as Welcome message value.
+
 2009-08-24  Atsushi Enomoto  <[email protected]>
 
 	* Constants.cs : p2p constants should rather go here.

+ 1 - 1
mcs/class/System.ServiceModel/System.ServiceModel/PeerNode.cs

@@ -49,7 +49,7 @@ namespace System.ServiceModel
 
 		internal string MeshId { get; private set; }
 
-		internal int NodeId { get; set; }
+		internal ulong NodeId { get; set; }
 
 		internal bool IsOpen {
 			get { return RegisteredId != null; }