Example #1
0
        public void Send(PeerHash peer, SenderMessage message)
        {
            NetworkConnection connection = context.Collection.Find(peer);
            SenderDefinition  definition = context.Configuration.Definition;

            if (connection == null)
            {
                context.Hooks.CallMessageIgnored(peer, message.Type, message);
                return;
            }

            string type       = message.Type;
            byte?  identifier = definition?.GetIdentifier(type);

            if (identifier != null)
            {
                connection.Send(message.Apply(identifier.Value));
                context.Hooks.CallMessageSent(peer, type, message);
            }
            else
            {
                context.Hooks.CallMessageIgnored(peer, type, message);
                message.Release();
            }
        }
Example #2
0
 public SenderBuilder WithDefinition(SenderDefinition definition)
 {
     configuration.Definition = definition;
     return(this);
 }