Inheritance: YPChannel.Transport.Sockets.IDiscoveryMessageBase
コード例 #1
0
        //-------------------------------------------------------------------------------------------------------------------------
        private bool YPChannel_Negotiation(YPChannel.Channel Channel)
        {
            DebugEx.TraceLog($"RemoteNode : Negotiation started with node. (ip:{IPAddress} port:{RemotePort} nodekey:{RemoteNodeKey})");

            //check
            if (Channel.ChannelRole != YPChannel.ChannelRole.Server)
            {
                DebugEx.Assert("Should not be here");
                return(false);
            }

            //---------------------
            // Association Request
            //---------------------
            {
                //send request
                var req = new AssociationRequest()
                {
                    UnsafeNodeKey = Node.NodeKey,
                    PublicKey     = null,
                };
                var rsp = Channel.SendRequest <AssociationResponse>(req);
                if (rsp == null)
                {
                    return(false);
                }

                //keep discovery message
                DiscoveryMessage    = rsp.DiscoveryMessage;
                RemoteEndpointID.ID = rsp.DiscoveryMessage.Id;
                //examine discovery message
                //..

                //keep node key
                RemoteNodeKey = rsp.UnsafeNodeKey;
                if (RemoteNodeKey.IsInvalid)
                {
                    return(false);
                }

                //keep public key

                /*
                 * if (rsp.PublicKey == null || rsp.PublicKey.Length == 0 || rsp.PublicKey.Length > 1024 * 20)
                 *  return false;
                 * else*/
                PublicKey = rsp.PublicKey;
            }

            //---------------------
            // Authentication Request
            //---------------------
            //..

            //all ok
            return(true);
        }
コード例 #2
0
ファイル: NodeDiscoverManager.cs プロジェクト: sm6uax/plegma
        //------------------------------------------------------------------------------------------------------------------------
        #endregion

        #region Constructor
        //------------------------------------------------------------------------------------------------------------------------
        public NodeDiscoverManager(Node Node, int YPCPort = DefaultYPCPort)
        {
            this.Node    = Node;
            this.YPCPort = YPCPort;

            //build flags
            var flags = NodeFlags.None;

            if (Node.CanSolveGraphs)
            {
                flags |= NodeFlags.CanSolveGraphs;
            }

            //create outgoing message
#if NETFX
            var version = Assembly.GetExecutingAssembly().GetName().Version;
            DiscoveryMessage = new DiscoveryMessage()
            {
                ProtocolVersion = Protocol.Version,
                MajorVersion    = version.Major,
                MinorVersion    = version.Minor,
                BuildVersion    = version.Build,
                Flags           = (int)flags,
            };
#else
            DiscoveryMessage = new DiscoveryMessage()
            {
                ProtocolVersion = Protocol.Version,
                MajorVersion    = Package.Current.Id.Version.Major,
                MinorVersion    = Package.Current.Id.Version.Minor,
                BuildVersion    = Package.Current.Id.Version.Build,
                Flags           = (int)flags,
            };
#endif

            //create discoverer
            Discoverer = new YPChannel.Transport.Sockets.LANDiscoverer(DiscoveryMessage, BroadcastPort: BroadcastPort);
            Discoverer.OnEndpointMsgRx   += Discoverer_OnEndpointMsgRx;
            Discoverer.OnEndpointTimeout += Discoverer_OnEndpointTimeout;

            //hook event for shutdown
            YPChannel.Channel.OnSystemShutDownRequest.Add(Yodiwo.WeakAction <object> .Create(Deinitialize));
        }
コード例 #3
0
ファイル: NodeDiscoverManager.cs プロジェクト: yodiwo/plegma
        //------------------------------------------------------------------------------------------------------------------------
        #endregion

        #region Constructor
        //------------------------------------------------------------------------------------------------------------------------
        public NodeDiscoverManager(Node Node, int YPCPort = DefaultYPCPort)
        {
            this.Node = Node;
            this.YPCPort = YPCPort;

            //build flags
            var flags = NodeFlags.None;
            if (Node.CanSolveGraphs) flags |= NodeFlags.CanSolveGraphs;

            //create outgoing message
#if NETFX
            var version = Assembly.GetExecutingAssembly().GetName().Version;
            DiscoveryMessage = new DiscoveryMessage()
            {
                ProtocolVersion = Protocol.Version,
                MajorVersion = version.Major,
                MinorVersion = version.Minor,
                BuildVersion = version.Build,
                Flags = (int)flags,
            };
#else
            DiscoveryMessage = new DiscoveryMessage()
            {
                ProtocolVersion = Protocol.Version,
                MajorVersion = Package.Current.Id.Version.Major,
                MinorVersion = Package.Current.Id.Version.Minor,
                BuildVersion = Package.Current.Id.Version.Build,
                Flags = (int)flags,
            };
#endif

            //create discoverer
            Discoverer = new YPChannel.Transport.Sockets.LANDiscoverer(DiscoveryMessage, BroadcastPort: BroadcastPort);
            Discoverer.OnEndpointMsgRx += Discoverer_OnEndpointMsgRx;
            Discoverer.OnEndpointTimeout += Discoverer_OnEndpointTimeout;

            //hook event for shutdown
            YPChannel.Channel.OnSystemShutDownRequest.Add(Yodiwo.WeakAction<object>.Create(Deinitialize));
        }