Exemplo n.º 1
0
        public IEnumerator ClientNotifySendCallbacksMarkedAsReceived()
        {
            byte[] message = Enumerable.Range(10, 20).Select(x => (byte)x).ToArray();

            var callBacks = new INotifyCallBack[ClientCount];

            // send 1 message from each client
            for (int i = 0; i < ClientCount; i++)
            {
                callBacks[i] = Substitute.For <INotifyCallBack>();
                clientConnections[i].SendNotify(message, callBacks[i]);
            }

            float end = UnityEngine.Time.time + NotifyWaitTime;

            while (end > UnityEngine.Time.time)
            {
                UpdateAll();
                yield return(null);
            }

            for (int i = 0; i < ClientCount; i++)
            {
                callBacks[i].Received(1).OnDelivered();
                callBacks[i].DidNotReceive().OnLost();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// This function Packs a message and sends it to the player's connection, This function may be added to NetworkPlayer in the future
        /// </summary>
        /// <param name="message"></param>
        /// <param name="callBacks"></param>
        public void SendNotify(Changes message, INotifyCallBack callBacks)
        {
            using (var writer = NetworkWriterPool.GetWriter())
            {
                MessagePacker.Pack(message, writer);

                var segment = writer.ToArraySegment();
                player.Connection.SendNotify(segment, callBacks);
            }
        }
Exemplo n.º 3
0
 public static void Notify(this INotifyCallBack callBack, bool delivered)
 {
     if (delivered)
     {
         callBack.OnDelivered();
     }
     else
     {
         callBack.OnLost();
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// This sends a network message to the connection.
        /// </summary>
        /// <typeparam name="T">The message type</typeparam>
        /// <param name="msg">The message to send.</param>
        /// <param name="channelId">The transport layer channel to send on.</param>
        /// <returns></returns>
        public void Send <T>(T message, INotifyCallBack token)
        {
            if (isDisconnected)
            {
                return;
            }

            using (PooledNetworkWriter writer = NetworkWriterPool.GetWriter())
            {
                MessagePacker.Pack(message, writer);

                var segment = writer.ToArraySegment();
                NetworkDiagnostics.OnSend(message, segment.Count, 1);
                connection.SendNotify(segment, token);
            }
        }
Exemplo n.º 5
0
 public void SendNotify(byte[] data, INotifyCallBack callbacks)
 {
     connection.SendNotify(data, callbacks);
 }
Exemplo n.º 6
0
 public void Send <T>(T message, INotifyCallBack notifyCallBack)
 {
     Player.Send(message, notifyCallBack);
 }