Exemple #1
0
        //-------------------------------------------------------------------------------------------------------------------------
        private void YPChannel_OnMessageReceived(YPChannel.Channel Channel, YPChannel.YPMessage Message)
        {
            var _msg = Message.Payload;

            //handle negotiation
            if (_msg is AssociationRequest && Channel.ChannelRole == YPChannel.ChannelRole.Client)
            {
                DebugEx.TraceLog($"RemoteNode : Sending negotiation AssociationResponse. (ip:{IPAddress} port:{RemotePort} nodekey:{RemoteNodeKey})");
                var rsp = new AssociationResponse()
                {
                    DiscoveryMessage = NodeDiscoverManager.DiscoveryMessage,
                    UnsafeNodeKey    = Node.NodeKey,
                    PublicKey        = null,
                };
                Channel.SendResponseAsync(rsp, Message.MessageID);
            }
            else if (_msg is AuthenticationRequest && Channel.ChannelRole == YPChannel.ChannelRole.Client)
            {
                //...
            }
            else if (_msg is VirtualBlockEventMsg)
            {
                var msg = _msg as VirtualBlockEventMsg;
                var rsp = new GenericRsp()
                {
                    IsSuccess = false
                };
                //validate msg
                if (msg.BlockEvents.Any(b => ((BlockKey)b.BlockKey).GraphKey.NodeKey != Node.NodeKey))
                {
                    DebugEx.Assert("Received VirtualBlockEventMsg that was not for me");
                    Channel.SendResponse(rsp, Message.MessageID);
                    return;
                }
                //respond with success
                rsp.IsSuccess = true;
                Channel.SendResponse(rsp, Message.MessageID);
                //raise event
                OnVBMReceived?.Invoke(this, msg);
            }
            else
            {
                DebugEx.Assert("Unkown message received");
            }
        }
Exemple #2
0
 //------------------------------------------------------------------------------------------------------------------------
 private void RemoteNode_OnVBMReceived(RemoteNode RemoteNode, VirtualBlockEventMsg msg)
 {
     OnVBMReceived?.Invoke(RemoteNode.RemoteNodeKey, msg);
 }