public NetOutgoingMessage CreateMessage(NetOutgoingMessageContext context, IEnumerable <NetConnection> recipients)
        {
            var container = new NetOutgoingMessageContainer(context, _peer.CreateMessage(), recipients);

            _containers.Enqueue(container);

            return(container.Message);
        }
Exemple #2
0
        /// <summary>
        /// Create & return a new <see cref="NetOutgoingMessage"/> instance configured
        /// for the current message type & enqueue to be sent.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="recipients">A list of connections who should be reciving the current message.</param>
        /// <returns></returns>
        public NetOutgoingMessage Create(NetOutgoingMessageContext context, IEnumerable <NetConnection> recipients)
        {
            var message = _factory(context, recipients);

            this.TryWrite(message);

            return(message);
        }
Exemple #3
0
        public MessageTypeManager(UInt32 id, Func <NetOutgoingMessageContext, IEnumerable <NetConnection>, NetOutgoingMessage> factory, Action <NetOutgoingMessage> signer, NetOutgoingMessageContext defaultContext = null)
        {
            this.Id             = id;
            this.DefaultContext = defaultContext;

            _factory = factory;
            _signer  = signer;
        }
 public NetOutgoingMessageContainer(
     NetOutgoingMessageContext context,
     NetOutgoingMessage message,
     IEnumerable <NetConnection> recipients)
 {
     this.Context    = context;
     this.Message    = message;
     this.Recipients = recipients;
 }
Exemple #5
0
 public void Add(UInt32 messageType, NetOutgoingMessageContext defaultContext = null, Func <NetOutgoingMessageContext, IEnumerable <NetConnection>, NetOutgoingMessage> factory = null)
 {
     _messageTypes.Add(messageType, new MessageTypeManager(messageType, factory ?? this.DefaultFactory, this.Signer, defaultContext));
 }
 private NetOutgoingMessage DeleteMessageFactory(NetOutgoingMessageContext context, IEnumerable <NetConnection> recipients)
 => _scene.Channel.Messages[Guppy.Network.Constants.Messages.Channel.DeleteNetworkEntity].Create(context, recipients);
 private NetOutgoingMessage CreateMessageFactory(NetOutgoingMessageContext context, IEnumerable <NetConnection> recipients)
 => _scene.Channel.Messages[Guppy.Network.Constants.Messages.Channel.CreateNetworkEntity].Create(context, recipients).Then(om =>
 {
     om.Write(this.Entity.ServiceConfiguration.Key.Id);
 });
Exemple #8
0
 /// <summary>
 /// <para>Create a new <see cref="NetOutgoingMessage"/> instance configured
 /// for the current message type, invoke the custom writer, then
 /// enqueue to be sent.</para>
 ///
 /// <para>Note, the recieving <see cref="MessageTypeManager"/> must still be configured to process
 /// the incoming message.</para>
 /// </summary>
 /// <param name="context"></param>
 /// <param name="writer"></param>
 /// <param name="recipients">A list of connections who should be reciving the current message.</param>
 /// <returns></returns>
 public void Create(NetOutgoingMessageContext context, Action <NetOutgoingMessage> writer, IEnumerable <NetConnection> recipients)
 => writer(this.Create(context, recipients));
Exemple #9
0
 /// <summary>
 /// <para>Create a new <see cref="NetOutgoingMessage"/> instance configured
 /// for the current message type, invoke the custom writer, then
 /// enqueue to be sent.</para>
 ///
 /// <para>Note, the recieving <see cref="MessageTypeManager"/> must still be configured to process
 /// the incoming message.</para>
 /// </summary>
 /// <param name="context"></param>
 /// <param name="writer"></param>
 /// <param name="recipients">A list of connections who should be reciving the current message.</param>
 /// <returns></returns>
 public void Create(NetOutgoingMessageContext context, Action <NetOutgoingMessage> writer, IPipe recipients)
 => writer(this.Create(context, recipients.Users.Connections));
Exemple #10
0
 /// <summary>
 /// Create & return a new <see cref="NetOutgoingMessage"/> instance configured
 /// for the current message type & enqueue to be sent.
 /// </summary>
 /// <param name="context"></param>
 /// <param name="recipients">A list of connections who should be reciving the current message.</param>
 /// <returns></returns>
 public NetOutgoingMessage Create(NetOutgoingMessageContext context, IPipe recipients)
 => Create(context, recipients.Users.Connections);