Esempio n. 1
0
        public void SendDirect(byte[] data, Guid destinationID)
        {
            Guid messageID = Guid.NewGuid();
             NetworkMessage[] fragments = null;
             TickGuid expiryTime = new TickGuid();
             expiryTime.id = messageID;

             NetworkMessage message = new NetworkMessage(localID, destinationID, messageID, NetworkMessageType.Message,
            data, 1, 1, 10000);

             if (message.GzData.Length > FragmentSize)
             {
            message.Lifetime = 30000;
            //Break the message up if it's large
            fragments = this.Fragment(message);
            expiryTime.SetExpityTime(message.Lifetime);
             }
             else
             {
            fragments = new NetworkMessage[1];
            fragments[0] = message;
            expiryTime.SetExpityTime(message.Lifetime);
             }

             Debug.WriteLine(String.Format("Adding {0} to store in {1} fragments", messageID, fragments.Length));
             outgoingFragments[messageID] = fragments;
             messageExpiryTimes.Add(expiryTime);

             // make the lifetime of the direct request message 5 seconds
             NetworkMessage directRequestMessage = new NetworkMessage(localID, destinationID, Guid.NewGuid(), NetworkMessageType.DirectRequest, messageID.ToByteArray(), 1, 1, 5000);
             sendMessage(directRequestMessage);
             startMessageLifetimeTimer();
        }