Пример #1
0
        /// <summary>
        /// Sends the specified <see cref="ITinyNetMessage"/>.
        /// </summary>
        /// <param name="msg">The message.</param>
        /// <param name="options">The options.</param>
        public void Send(ITinyNetMessage msg, DeliveryMethod options)
        {
            recycleWriter.Reset();

            recycleWriter.Put(msg.msgType);
            msg.Serialize(recycleWriter);

            Send(recycleWriter, options);
        }
Пример #2
0
        /// <summary>
        /// Sends the message by a specific channel to target connection.
        /// </summary>
        /// <param name="msg">The message.</param>
        /// <param name="sendOptions">The send options.</param>
        /// <param name="tinyNetConn">The connection.</param>
        public virtual void SendMessageByChannelToTargetConnection(ITinyNetMessage msg, DeliveryMethod sendOptions, TinyNetConnection tinyNetConn)
        {
            recycleWriter.Reset();

            recycleWriter.Put(msg.msgType);
            msg.Serialize(recycleWriter);

            tinyNetConn.Send(recycleWriter, sendOptions);
        }
Пример #3
0
        /// <summary>
        /// Sends the message by a specific channel to host.
        /// </summary>
        /// <param name="msg">The message.</param>
        /// <param name="sendOptions">The send options.</param>
        public virtual void SendMessageByChannelToHost(ITinyNetMessage msg, DeliveryMethod sendOptions)
        {
            recycleWriter.Reset();

            recycleWriter.Put(msg.msgType);
            msg.Serialize(recycleWriter);

            connToHost.Send(recycleWriter, sendOptions);
        }
Пример #4
0
        /// <summary>
        /// Sends the message by a specific channel to all connections.
        /// </summary>
        /// <param name="msg">The message.</param>
        /// <param name="sendOptions">The send options.</param>
        public virtual void SendMessageByChannelToAllConnections(ITinyNetMessage msg, DeliveryMethod sendOptions)
        {
            recycleWriter.Reset();

            recycleWriter.Put(msg.msgType);
            msg.Serialize(recycleWriter);

            for (int i = 0; i < tinyNetConns.Count; i++)
            {
                tinyNetConns[i].Send(recycleWriter, sendOptions);
            }
        }
Пример #5
0
        /// <summary>
        /// Sends the message by a specific channel to all observers of a <see cref="TinyNetIdentity"/>.
        /// </summary>
        /// <param name="tni">The <see cref="TinyNetIdentity"/>.</param>
        /// <param name="msg">The message.</param>
        /// <param name="sendOptions">The send options.</param>
        public virtual void SendMessageByChannelToAllObserversOf(TinyNetIdentity tni, ITinyNetMessage msg, DeliveryMethod sendOptions)
        {
            recycleWriter.Reset();

            recycleWriter.Put(msg.msgType);
            msg.Serialize(recycleWriter);

            for (int i = 0; i < tinyNetConns.Count; i++)
            {
                if (!tinyNetConns[i].IsObservingNetIdentity(tni))
                {
                    return;
                }
                tinyNetConns[i].Send(recycleWriter, sendOptions);
            }
        }